[pango/simple-fontmap: 17/18] wip: extent transform fixes




commit 4b6db42ff5ee868be820ed6ed01ee6ccc6951e6d
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Oct 26 23:49:35 2021 -0400

    wip: extent transform fixes

 pango/pango-hbfont.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/pango/pango-hbfont.c b/pango/pango-hbfont.c
index a17f52bf..5a3543c0 100644
--- a/pango/pango-hbfont.c
+++ b/pango/pango-hbfont.c
@@ -415,21 +415,33 @@ pango_hb_font_get_glyph_extents (PangoFont      *font,
 
       pango_matrix_transform_rectangle (&self->face->matrix, ink_rect);
 
-      /* FIXME: why is this required */
       pango_matrix_rotate (&matrix, - pango_gravity_to_rotation (PANGO_HB_FONT (font)->gravity) * 180. / 
G_PI);
       pango_matrix_transform_rectangle (&matrix, ink_rect);
     }
 
   if (logical_rect)
     {
-      hb_position_t x, y;
+      PangoMatrix matrix = PANGO_MATRIX_INIT;
+
+      if (PANGO_GRAVITY_IS_VERTICAL (self->gravity))
+        {
+          logical_rect->height = hb_font_get_glyph_v_advance (hb_font, glyph);
+          logical_rect->y = - logical_rect->height;
+          logical_rect->x = - (font_extents.ascender - font_extents.descender) / 2;
+          logical_rect->width = logical_rect->x + font_extents.ascender - font_extents.descender;
+        }
+      else
+        {
+          logical_rect->x = 0;
+          logical_rect->width = hb_font_get_glyph_h_advance (hb_font, glyph);
+          logical_rect->y = - font_extents.ascender;
+          logical_rect->height = font_extents.ascender - font_extents.descender;
+        }
 
-      hb_font_get_glyph_advance_for_direction (hb_font, glyph, direction, &x, &y);
+      pango_matrix_transform_rectangle (&self->face->matrix, logical_rect);
 
-      logical_rect->x = 0;
-      logical_rect->width = x;
-      logical_rect->y = - font_extents.ascender;
-      logical_rect->height = font_extents.ascender - font_extents.descender;
+      pango_matrix_rotate (&matrix, - pango_gravity_to_rotation (PANGO_HB_FONT (font)->gravity) * 180. / 
G_PI);
+      pango_matrix_transform_rectangle (&matrix, logical_rect);
     }
 }
 


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