From cdc77f57773bfb4639f15b77a14736658a3d9926 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Mon, 2 May 2005 21:22:19 +0000 Subject: Get the ascent/descent from Cairo to fix bugs in metrics computation with 2005-04-29 Owen Taylor * pango/pangocairo-fcfont.c (pango_cairo_fc_font_get_glyph_extents): Get the ascent/descent from Cairo to fix bugs in metrics computation with a transformation in effect. --- ChangeLog | 10 +++++----- ChangeLog.pre-1-10 | 10 +++++----- pango/pangocairo-fcfont.c | 31 +++++++------------------------ 3 files changed, 17 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index 057ce96f..98e77f1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,14 +1,14 @@ -2005-05-01 Owen Taylor - - * examples/cairoview.c: Fix for the change of cairo_clip() not to preserve - the path. - 2005-04-29 Owen Taylor * pango/pangocairo-fcfont.c (pango_cairo_fc_font_get_glyph_extents): Get the ascent/descent from Cairo to fix bugs in metrics computation with a transformation in effect. +2005-05-01 Owen Taylor + + * examples/cairoview.c: Fix for the change of cairo_clip() not to preserve + the path. + 2005-04-28 Tor Lillqvist * pango/pangocairo-win32font.c (pango_cairo_win32_font_get_font_face): diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index 057ce96f..98e77f1a 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,14 +1,14 @@ -2005-05-01 Owen Taylor - - * examples/cairoview.c: Fix for the change of cairo_clip() not to preserve - the path. - 2005-04-29 Owen Taylor * pango/pangocairo-fcfont.c (pango_cairo_fc_font_get_glyph_extents): Get the ascent/descent from Cairo to fix bugs in metrics computation with a transformation in effect. +2005-05-01 Owen Taylor + + * examples/cairoview.c: Fix for the change of cairo_clip() not to preserve + the path. + 2005-04-28 Tor Lillqvist * pango/pangocairo-win32font.c (pango_cairo_win32_font_get_font_face): diff --git a/pango/pangocairo-fcfont.c b/pango/pangocairo-fcfont.c index 27a20e0e..7b2d9243 100644 --- a/pango/pangocairo-fcfont.c +++ b/pango/pangocairo-fcfont.c @@ -146,26 +146,6 @@ pango_cairo_fc_font_finalize (GObject *object) G_OBJECT_CLASS (pango_cairo_fc_font_parent_class)->finalize (object); } -static void -get_ascent_descent (PangoCairoFcFont *cffont, - int *ascent, - int *descent) -{ - PangoFcFont *fcfont = PANGO_FC_FONT (cffont); - FT_Face face; - - face = pango_fc_font_lock_face (fcfont); - - /* This is complicated in general (see pangofc-font.c:get_face_metrics(), - * but simple for hinted, untransformed fonts. cairo_glyph_extents() will - * have set up the right size on the font as a side-effect. - */ - *descent = - PANGO_UNITS_26_6 (face->size->metrics.descender); - *ascent = PANGO_UNITS_26_6 (face->size->metrics.ascender); - - pango_fc_font_unlock_face (fcfont); -} - static void pango_cairo_fc_font_get_glyph_extents (PangoFont *font, PangoGlyph glyph, @@ -196,14 +176,17 @@ pango_cairo_fc_font_get_glyph_extents (PangoFont *font, if (logical_rect) { - int ascent, descent; + /* It may well be worth caching the font_extents here, since getting them + * is pretty expensive. + */ + cairo_font_extents_t font_extents; - get_ascent_descent (cffont, &ascent, &descent); + cairo_scaled_font_extents (scaled_font, &font_extents); logical_rect->x = 0; - logical_rect->y = - ascent; + logical_rect->y = - font_extents.ascent * PANGO_SCALE; logical_rect->width = extents.x_advance * PANGO_SCALE; - logical_rect->height = ascent + descent; + logical_rect->height = (font_extents.ascent + font_extents.descent) * PANGO_SCALE; } } -- cgit v1.2.1