summaryrefslogtreecommitdiff
path: root/pango/pangocairo-font.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-10-30 12:40:36 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-10-30 21:28:34 -0400
commit51881a59b2622662583bf212fa6f1a9df67b2090 (patch)
tree76739e0c0497be783c427ee9172ce005b512a4a6 /pango/pangocairo-font.c
parent9702ab5891309404cb35ece64f5029a095897b65 (diff)
downloadpango-51881a59b2622662583bf212fa6f1a9df67b2090.tar.gz
cairo: Produce meaningful logical glyph extents
Depending on gravity, our logical glyph extents were empty and mis-aligned. Fix that.
Diffstat (limited to 'pango/pangocairo-font.c')
-rw-r--r--pango/pangocairo-font.c39
1 files changed, 28 insertions, 11 deletions
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 ();
+ }
}
}