diff src/shape_text.c @ 285:248a40d51473

Check in test program for sh_text_set_text for debugging. It is not working yet.
author wycc
date Sat, 31 Jan 2009 16:52:28 +0800
parents c8b6ca46950b
children 13ce87b6dbf5
line wrap: on
line diff
--- a/src/shape_text.c	Sat Jan 31 13:03:56 2009 +0800
+++ b/src/shape_text.c	Sat Jan 31 16:52:28 2009 +0800
@@ -110,17 +110,17 @@
     //printf("x=%f y=%f text=%s ascent=%d,descent=%d,width=%d height=%d\n", x,y,text->data,PANGO_ASCENT(extents), PANGO_DESCENT(extents), extents.width, extents.height);
     ASSERT(r == OK);
 
-    text->d_x = x;
-    text->d_y = y-text->font_size;
+    text->d_x = x-5;
+    text->d_y = y-PANGO_DESCENT(extents)+5;
     shw = shape->stroke_width / 2;
     /* FIXME: It is unreasonable that a font exceed it's bbox.
      * We add 5 pixels in get right bbox.  But, it is unreasonable.
      */
 
-    poses[0][0] = x + extents.x - 5 - shw;
-    poses[0][1] = y + extents.y - 5 - shw;
-    poses[1][0] = poses[0][0] + extents.width + 10 + shape->stroke_width;
-    poses[1][1] = poses[0][1] + extents.height + 10 + shape->stroke_width;
+    poses[0][0] = x + extents.x - shw;
+    poses[0][1] = y + extents.y - shw;
+    poses[1][0] = poses[0][0] + extents.width +  shape->stroke_width;
+    poses[1][1] = poses[0][1] + extents.height +  shape->stroke_width;
     geo_from_positions(shape->geo, 2, poses);
     /*! \todo Support ratation for shape_text. */
 }
@@ -136,10 +136,11 @@
     }
     text->layout = pango_cairo_create_layout(cr);
     desc = pango_font_description_from_string("Sans Bold");
+    cairo_set_source_rgb (cr, 0, 0, 0);
     pango_layout_set_font_description (text->layout, desc);
-    pango_cairo_update_layout(cr,text->layout);
     pango_layout_set_text(text->layout,text->data,strlen(text->data));
     pango_layout_set_attributes(text->layout, text->attrs);
+    pango_cairo_update_layout(cr,text->layout);
 }
 static void draw_text(sh_text_t *text, cairo_t *cr) {
     sh_text_P_generate_layout(text, cr);