]> granicus.if.org Git - graphviz/commitdiff
better way to get baseline
authorellson <devnull@localhost>
Fri, 11 Feb 2011 20:42:15 +0000 (20:42 +0000)
committerellson <devnull@localhost>
Fri, 11 Feb 2011 20:42:15 +0000 (20:42 +0000)
contrib/pangotest/pangotest.c
plugin/pango/gvtextlayout_pango.c

index e18d52093014b345d1ad1f2a213262ba0fd6c4a0..f474497dbf198f3d6ab034006cc2d9065631670c 100644 (file)
@@ -17,7 +17,6 @@ static void draw_text(cairo_t *cr, char *text, char *font_family, double font_si
        PangoFontDescription *desc;
        PangoRectangle logical_rect, ink_rect;
        PangoRectangle pixel_logical_rect, pixel_ink_rect;
-       PangoLayoutIter *iter;
        PangoFont *font;
        PangoFontMetrics *fontmetrics;
        cairo_font_options_t *options;
@@ -39,6 +38,7 @@ static void draw_text(cairo_t *cr, char *text, char *font_family, double font_si
        }
        
        layout = pango_layout_new(context);
+       pango_layout_set_spacing(layout,0);
        pango_layout_set_text(layout,text,-1);
        desc = pango_font_description_from_string(font_family);
        pango_font_description_set_size (desc, (gint)(font_size * PANGO_SCALE));
@@ -84,9 +84,7 @@ static void draw_text(cairo_t *cr, char *text, char *font_family, double font_si
 
        /* draw baseline - red */
        cairo_set_source_rgb(cr,1.0,0.0,0.0);
-       iter = pango_layout_get_iter(layout);
-       baseline = pango_layout_iter_get_baseline (iter);
-
+       baseline = pango_layout_get_baseline (layout);
        cairo_move_to(cr,logical_rect.x / PANGO_SCALE, baseline / PANGO_SCALE);
        cairo_rel_line_to(cr,logical_rect.width / PANGO_SCALE, 0);
        cairo_stroke(cr);
index 49e910ed6d2a67dc6150a57f0e5acd91abae850e..a657551f06f880e375d80f7019f4b04732667156 100644 (file)
@@ -70,7 +70,6 @@ static boolean pango_textlayout(textpara_t * para, char **fontpath)
     char *fnt, *psfnt = NULL;
     PangoLayout *layout;
     PangoRectangle logical_rect;
-    PangoLayoutIter* iter;
     cairo_font_options_t* options;
     PangoFont *font;
 #ifdef ENABLE_PANGO_MARKUP
@@ -222,13 +221,11 @@ static boolean pango_textlayout(textpara_t * para, char **fontpath)
     para->height = (int)(logical_rect.height * textlayout_scale + 1);
 
     /* The y offset from baseline to 0,0 of the bitmap representation */
-    iter = pango_layout_get_iter (layout);
-    para->yoffset_layout = pango_layout_iter_get_baseline (iter) * textlayout_scale;
+    para->yoffset_layout = pango_layout_get_baseline (layout) * textlayout_scale;
 
     /* The distance below midline for y centering of text strings */
     para->yoffset_centerline = 0.10 * para->fontsize;
 
-    pango_layout_iter_free (iter);
     if (logical_rect.width == 0)
        return FALSE;
     return TRUE;