From 51881a59b2622662583bf212fa6f1a9df67b2090 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 30 Oct 2021 12:40:36 -0400 Subject: cairo: Produce meaningful logical glyph extents Depending on gravity, our logical glyph extents were empty and mis-aligned. Fix that. --- pango/pangocairo-font.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'pango/pangocairo-font.c') diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c index 69c375c3..35380571 100644 --- a/pango/pangocairo-font.c +++ b/pango/pangocairo-font.c @@ -800,19 +800,19 @@ _pango_cairo_font_private_glyph_extents_cache_init (PangoCairoFontPrivate *cf_pr default: case PANGO_GRAVITY_AUTO: case PANGO_GRAVITY_SOUTH: - cf_priv->font_extents.y = - pango_units_from_double (font_extents.ascent); - break; + cf_priv->font_extents.y = - pango_units_from_double (font_extents.ascent); + break; case PANGO_GRAVITY_NORTH: - cf_priv->font_extents.y = - pango_units_from_double (font_extents.descent); - break; + cf_priv->font_extents.y = - pango_units_from_double (font_extents.descent); + break; case PANGO_GRAVITY_EAST: case PANGO_GRAVITY_WEST: - { - int ascent = pango_units_from_double (font_extents.ascent + font_extents.descent) / 2; - if (cf_priv->is_hinted) - ascent = PANGO_UNITS_ROUND (ascent); - cf_priv->font_extents.y = - ascent; - } + { + int ascent = pango_units_from_double (font_extents.ascent + font_extents.descent) / 2; + if (cf_priv->is_hinted) + ascent = PANGO_UNITS_ROUND (ascent); + cf_priv->font_extents.y = - ascent; + } } cf_priv->glyph_extents_cache = g_new0 (PangoCairoFontGlyphExtentsCacheEntry, GLYPH_CACHE_NUM_ENTRIES); @@ -904,6 +904,23 @@ _pango_cairo_font_private_get_glyph_extents (PangoCairoFontPrivate *cf_priv, if (logical_rect) { *logical_rect = cf_priv->font_extents; - logical_rect->width = entry->width; + switch (cf_priv->gravity) + { + case PANGO_GRAVITY_SOUTH: + logical_rect->width = entry->width; + break; + case PANGO_GRAVITY_EAST: + logical_rect->width = cf_priv->font_extents.height; + break; + case PANGO_GRAVITY_NORTH: + logical_rect->width = entry->width; + break; + case PANGO_GRAVITY_WEST: + logical_rect->width = - cf_priv->font_extents.height; + break; + case PANGO_GRAVITY_AUTO: + default: + g_assert_not_reached (); + } } } -- cgit v1.2.1