[pango/glyph-extents-fixes: 2/5] cairo: Produce meaningful logical glyph extents
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/glyph-extents-fixes: 2/5] cairo: Produce meaningful logical glyph extents
- Date: Sun, 31 Oct 2021 01:29:39 +0000 (UTC)
commit 51881a59b2622662583bf212fa6f1a9df67b2090
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Oct 30 12:40:36 2021 -0400
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(-)
---
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 ();
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]