From dbf2d58b91f3e38683675e4e711fdb2c98b0348a Mon Sep 17 00:00:00 2001 From: ellson Date: Fri, 11 Feb 2011 20:42:15 +0000 Subject: [PATCH] better way to get baseline --- contrib/pangotest/pangotest.c | 6 ++---- plugin/pango/gvtextlayout_pango.c | 5 +---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/contrib/pangotest/pangotest.c b/contrib/pangotest/pangotest.c index e18d52093..f474497db 100644 --- a/contrib/pangotest/pangotest.c +++ b/contrib/pangotest/pangotest.c @@ -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); diff --git a/plugin/pango/gvtextlayout_pango.c b/plugin/pango/gvtextlayout_pango.c index 49e910ed6..a657551f0 100644 --- a/plugin/pango/gvtextlayout_pango.c +++ b/plugin/pango/gvtextlayout_pango.c @@ -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; -- 2.40.0