[pango/synthetic-slant: 2/2] Pass synthetic slant to harfbuzz




commit 1aa0162546921fd11a44b0bb34b2fa54fe0ff19c
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Sep 11 12:44:29 2021 -0400

    Pass synthetic slant to harfbuzz
    
    When our font matrix includes a slant, pass that information
    to HarfBuzz, so it can adjust its mark positioning, metrics
    like caret slope, etc.
    
    This commit corrects the code that pulls the font matrix out
    of fontconfig to properly take the flipped y axis between fontconfig
    and pango into account.
    
    Requires new api in HarfBuzz > 3.2

 pango/pangofc-font.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index 77e99e16..fb1cbce0 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -950,10 +950,12 @@ pango_fc_font_create_hb_font (PangoFont *font)
   double x_scale, y_scale;
   double pixel_size;
   double point_size;
+  double slant;
 
   x_scale_inv = y_scale_inv = 1.0;
   pixel_size = 1.0;
   point_size = 1.0;
+  slant = 0.0;
 
   key = _pango_fc_font_get_font_key (fc_font);
   if (key)
@@ -974,11 +976,12 @@ pango_fc_font_create_hb_font (PangoFont *font)
         FcMatrixMultiply (&fc_matrix, &fc_matrix, fc_matrix_val);
 
       font_matrix.xx = fc_matrix.xx;
-      font_matrix.yx = fc_matrix.yx;
+      font_matrix.yx = - fc_matrix.yx;
       font_matrix.xy = fc_matrix.xy;
-      font_matrix.yy = fc_matrix.yy;
+      font_matrix.yy = - fc_matrix.yy;
 
       pango_matrix_get_font_scale_factors (&font_matrix, &x, &y);
+      slant = pango_matrix_get_slant_ratio (&font_matrix);
 
       x_scale_inv /= x;
       y_scale_inv /= y;
@@ -989,6 +992,7 @@ pango_fc_font_create_hb_font (PangoFont *font)
           x_scale_inv = -x_scale_inv;
           y_scale_inv = -y_scale_inv;
         }
+
       get_font_size (key, &pixel_size, &point_size);
     }
 
@@ -1003,6 +1007,8 @@ pango_fc_font_create_hb_font (PangoFont *font)
                      pixel_size * PANGO_SCALE * y_scale);
   hb_font_set_ptem (hb_font, point_size);
 
+  hb_font_set_synthetic_slant (hb_font, slant);
+
   if (key)
     {
       const FcPattern *pattern = pango_fc_font_key_get_pattern (key);


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