changeset 2250:94dae4df1e10

Hope it's the final italics fix.
author Eugene Paskevich <eugene@raptor.kiev.ua>
date Wed, 19 Dec 2007 12:21:59 +0200
parents 2769f4aaa2fd
children 708f89aaee06
files src/aosd/aosd_osd.c src/aosd/aosd_style.c
diffstat 2 files changed, 36 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/aosd/aosd_osd.c	Sun Dec 16 11:42:38 2007 +0200
+++ b/src/aosd/aosd_osd.c	Wed Dec 19 12:21:59 2007 +0200
@@ -179,7 +179,7 @@
 aosd_osd_create ( void )
 {
   gint max_width, layout_width, layout_height;
-  PangoRectangle ink;
+  PangoRectangle ink, log;
   GdkScreen *screen = gdk_screen_get_default();
   gint pos_x = 0, pos_y = 0;
   gint pad_left = 0 , pad_right = 0 , pad_top = 0 , pad_bottom = 0;
@@ -229,9 +229,9 @@
   pango_layout_set_ellipsize( osd_data->pango_layout , PANGO_ELLIPSIZE_NONE );
   pango_layout_set_justify( osd_data->pango_layout , FALSE );
   pango_layout_set_width( osd_data->pango_layout , PANGO_SCALE * max_width );
-  pango_layout_get_pixel_extents( osd_data->pango_layout , &ink , NULL );
-  layout_width = ink.x + ink.width;
-  layout_height = ink.y + ink.height;
+  pango_layout_get_pixel_extents( osd_data->pango_layout , &ink , &log );
+  layout_width = ink.width;
+  layout_height = log.height;
 
   /* osd position */
   switch ( osd_data->cfg_osd->position.placement )
--- a/src/aosd/aosd_style.c	Sun Dec 16 11:42:38 2007 +0200
+++ b/src/aosd/aosd_style.c	Wed Dec 19 12:21:59 2007 +0200
@@ -161,6 +161,22 @@
 }
 
 
+// sizing helper
+static void
+aosd_layout_size( PangoLayout * layout , gint * width , gint * height , gint * bearing )
+{
+  PangoRectangle ink, log;
+
+  pango_layout_get_pixel_extents( layout , &ink , &log );
+
+  if ( width != NULL )
+    *width = ink.width;
+  if ( height != NULL )
+    *height = log.height;
+  if ( bearing != NULL )
+    *bearing = -ink.x;
+}
+
 
 /* RENDER FUNCTIONS */
 
@@ -178,9 +194,9 @@
   aosd_color_t textcolor0 = data->text->fonts_color[0];
   aosd_color_t shadowcolor0 = data->text->fonts_shadow_color[0];
   gboolean draw_shadow = data->text->fonts_draw_shadow[0];
-  gint width = 0, height = 0;
+  gint width = 0, height = 0, bearing = 0;
 
-  pango_layout_get_pixel_size( osd_layout , &width , &height );
+  aosd_layout_size( osd_layout , &width , &height , &bearing );
 
   /* draw rectangle container */
   cairo_set_source_rgba( cr , (gdouble)color0.red / 65535 , (gdouble)color0.green / 65535 ,
@@ -201,7 +217,7 @@
     cairo_set_source_rgba( cr , (gdouble)shadowcolor0.red / 65535 , (gdouble)shadowcolor0.green / 65535 ,
       (gdouble)shadowcolor0.blue / 65535 , (gdouble)shadowcolor0.alpha / 65535 );
     cairo_move_to( cr,
-      aosd_deco_styles[AOSD_DECO_STYLE_RECT].padding.left + 2 ,
+      aosd_deco_styles[AOSD_DECO_STYLE_RECT].padding.left + bearing + 2 ,
       aosd_deco_styles[AOSD_DECO_STYLE_RECT].padding.top + 2 );
     pango_cairo_show_layout( cr , osd_layout );
   }
@@ -210,7 +226,7 @@
   cairo_set_source_rgba( cr , (gdouble)textcolor0.red / 65535 , (gdouble)textcolor0.green / 65535 ,
     (gdouble)textcolor0.blue / 65535 , (gdouble)textcolor0.alpha / 65535 );
   cairo_move_to( cr,
-    aosd_deco_styles[AOSD_DECO_STYLE_RECT].padding.left ,
+    aosd_deco_styles[AOSD_DECO_STYLE_RECT].padding.left + bearing ,
     aosd_deco_styles[AOSD_DECO_STYLE_RECT].padding.top );
   pango_cairo_show_layout( cr , osd_layout );
 }
@@ -230,9 +246,9 @@
   aosd_color_t textcolor0 = data->text->fonts_color[0];
   aosd_color_t shadowcolor0 = data->text->fonts_shadow_color[0];
   gboolean draw_shadow = data->text->fonts_draw_shadow[0];
-  gint width = 0, height = 0;
+  gint width = 0, height = 0, bearing = 0;
 
-  pango_layout_get_pixel_size( osd_layout , &width , &height );
+  aosd_layout_size( osd_layout , &width , &height , &bearing );
 
   /* draw rounded-rectangle container */
   cairo_set_source_rgba( cr , (gdouble)color0.red / 65535 , (gdouble)color0.green / 65535 ,
@@ -262,7 +278,7 @@
     cairo_set_source_rgba( cr , (gdouble)shadowcolor0.red / 65535 , (gdouble)shadowcolor0.green / 65535 ,
       (gdouble)shadowcolor0.blue / 65535 , (gdouble)shadowcolor0.alpha / 65535 );
     cairo_move_to( cr ,
-      aosd_deco_styles[AOSD_DECO_STYLE_ROUNDRECT].padding.left + 2 ,
+      aosd_deco_styles[AOSD_DECO_STYLE_ROUNDRECT].padding.left + bearing + 2 ,
       aosd_deco_styles[AOSD_DECO_STYLE_ROUNDRECT].padding.top + 2 );
     pango_cairo_show_layout( cr , osd_layout );
   }
@@ -271,7 +287,7 @@
   cairo_set_source_rgba( cr , (gdouble)textcolor0.red / 65535 , (gdouble)textcolor0.green / 65535 ,
     (gdouble)textcolor0.blue / 65535 , (gdouble)textcolor0.alpha / 65535 );
   cairo_move_to( cr ,
-    aosd_deco_styles[AOSD_DECO_STYLE_ROUNDRECT].padding.left ,
+    aosd_deco_styles[AOSD_DECO_STYLE_ROUNDRECT].padding.left + bearing ,
     aosd_deco_styles[AOSD_DECO_STYLE_ROUNDRECT].padding.top );
   pango_cairo_show_layout( cr , osd_layout );
 }
@@ -291,9 +307,9 @@
   aosd_color_t textcolor0 = data->text->fonts_color[0];
   aosd_color_t shadowcolor0 = data->text->fonts_shadow_color[0];
   gboolean draw_shadow = data->text->fonts_draw_shadow[0];
-  gint width = 0, height = 0;
+  gint width = 0, height = 0, bearing = 0;
 
-  pango_layout_get_pixel_size( osd_layout , &width , &height );
+  aosd_layout_size( osd_layout , &width , &height , &bearing );
 
   /* draw jigsaw-piece-like container */
   cairo_set_source_rgba( cr , (gdouble)color0.red / 65535 , (gdouble)color0.green / 65535 ,
@@ -323,7 +339,7 @@
     cairo_set_source_rgba( cr , (gdouble)shadowcolor0.red / 65535 , (gdouble)shadowcolor0.green / 65535 ,
       (gdouble)shadowcolor0.blue / 65535 , (gdouble)shadowcolor0.alpha / 65535 );
     cairo_move_to( cr ,
-      aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.left + 2 ,
+      aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.left + bearing + 2 ,
       aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.top + 2 );
     pango_cairo_show_layout( cr , osd_layout );
   }
@@ -332,7 +348,7 @@
   cairo_set_source_rgba( cr , (gdouble)textcolor0.red / 65535 , (gdouble)textcolor0.green / 65535 ,
     (gdouble)textcolor0.blue / 65535 , (gdouble)textcolor0.alpha / 65535 );
   cairo_move_to( cr ,
-    aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.left ,
+    aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.left + bearing ,
     aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.top );
   pango_cairo_show_layout( cr , osd_layout );
 }
@@ -350,9 +366,9 @@
   aosd_color_t textcolor0 = data->text->fonts_color[0];
   aosd_color_t shadowcolor0 = data->text->fonts_shadow_color[0];
   gboolean draw_shadow = data->text->fonts_draw_shadow[0];
-  gint width = 0, height = 0;
+  gint width = 0, height = 0, bearing = 0;
 
-  pango_layout_get_pixel_size( osd_layout , &width , &height );
+  aosd_layout_size( osd_layout , &width , &height , &bearing );
 
   if ( draw_shadow == TRUE )
   {
@@ -360,7 +376,7 @@
     cairo_set_source_rgba( cr , (gdouble)shadowcolor0.red / 65535 , (gdouble)shadowcolor0.green / 65535 ,
       (gdouble)shadowcolor0.blue / 65535 , (gdouble)shadowcolor0.alpha / 65535 );
     cairo_move_to( cr ,
-      aosd_deco_styles[AOSD_DECO_STYLE_NONE].padding.left + 2 ,
+      aosd_deco_styles[AOSD_DECO_STYLE_NONE].padding.left + bearing + 2 ,
       aosd_deco_styles[AOSD_DECO_STYLE_NONE].padding.top + 2 );
     pango_cairo_show_layout( cr , osd_layout );
   }
@@ -369,7 +385,7 @@
   cairo_set_source_rgba( cr , (gdouble)textcolor0.red / 65535 , (gdouble)textcolor0.green / 65535 ,
     (gdouble)textcolor0.blue / 65535 , (gdouble)textcolor0.alpha / 65535 );
   cairo_move_to( cr ,
-    aosd_deco_styles[AOSD_DECO_STYLE_NONE].padding.left ,
+    aosd_deco_styles[AOSD_DECO_STYLE_NONE].padding.left + bearing ,
     aosd_deco_styles[AOSD_DECO_STYLE_NONE].padding.top );
   pango_cairo_show_layout( cr , osd_layout );
 }