[pango/simple-fontmap: 18/18] wip: attempts at extents




commit 4e534b1bea271086550b053ac01a45a558ec6932
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Oct 27 16:31:34 2021 -0400

    wip: attempts at extents

 pango/pangocairo-font.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c
index 25a5bb0d..ced32739 100644
--- a/pango/pangocairo-font.c
+++ b/pango/pangocairo-font.c
@@ -923,25 +923,26 @@ _pango_cairo_font_private_glyph_extents_cache_init (PangoCairoFontPrivate *cf_pr
 
   cf_priv->font_extents.x = 0;
   cf_priv->font_extents.width = 0;
-  cf_priv->font_extents.height = pango_units_from_double (font_extents.ascent + font_extents.descent);
   switch (cf_priv->gravity)
     {
       default:
       case PANGO_GRAVITY_AUTO:
       case PANGO_GRAVITY_SOUTH:
+        cf_priv->font_extents.height = pango_units_from_double (font_extents.ascent + font_extents.descent);
        cf_priv->font_extents.y = - pango_units_from_double (font_extents.ascent);
        break;
       case PANGO_GRAVITY_NORTH:
+        cf_priv->font_extents.height = pango_units_from_double (font_extents.ascent + font_extents.descent);
        cf_priv->font_extents.y = - pango_units_from_double (font_extents.descent);
        break;
       case PANGO_GRAVITY_EAST:
+        cf_priv->font_extents.height = pango_units_from_double (font_extents.max_x_advance);
+        cf_priv->font_extents.y = - cf_priv->font_extents.height / 2;
+        break;
       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;
-       }
+        cf_priv->font_extents.height = pango_units_from_double (font_extents.max_x_advance);
+        cf_priv->font_extents.y =  - cf_priv->font_extents.height / 2;
+        break;
     }
 
   cf_priv->glyph_extents_cache = g_new0 (PangoCairoFontGlyphExtentsCacheEntry, GLYPH_CACHE_NUM_ENTRIES);
@@ -970,7 +971,10 @@ compute_glyph_extents (PangoCairoFontPrivate  *cf_priv,
                                   &cairo_glyph, 1, &extents);
 
   entry->glyph = glyph;
-  entry->width = pango_units_from_double (extents.x_advance);
+  if (PANGO_GRAVITY_IS_VERTICAL (cf_priv->gravity))
+    entry->width = pango_units_from_double (extents.y_advance);
+  else
+    entry->width = pango_units_from_double (extents.x_advance);
   entry->ink_rect.x = pango_units_from_double (extents.x_bearing);
   entry->ink_rect.y = pango_units_from_double (extents.y_bearing);
   entry->ink_rect.width = pango_units_from_double (extents.width);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]