diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-12-19 21:20:26 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-12-19 21:53:16 -0500 |
commit | ab0441b7c9fda4cb6ee540c8231987c1b1b14340 (patch) | |
tree | 487cd9a3b5b378768fd93a454add7e193ec83c5f | |
parent | 0cbd693d96d0b2338cef5795d03d6b670368d24a (diff) | |
download | pango-matrix-decompose.tar.gz |
Pass synthetic slant to harfbuzzmatrix-decompose
This will let HarfBuzz adjust positioning
of marks and other things.
This requires new api HarfBuzz > 3.2.
-rw-r--r-- | pango/pangofc-font.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c index 77e99e16..90b1bf2f 100644 --- a/pango/pangofc-font.c +++ b/pango/pangofc-font.c @@ -28,6 +28,7 @@ #include "pango-layout.h" #include "pango-impl-utils.h" +#include <math.h> #include <hb-ot.h> enum { @@ -939,6 +940,8 @@ parse_variations (const char *variations, } } +#define DEG_TO_RAD(x) ((x) / 180.f * G_PI) + static hb_font_t * pango_fc_font_create_hb_font (PangoFont *font) { @@ -950,10 +953,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) @@ -963,7 +968,7 @@ pango_fc_font_create_hb_font (PangoFont *font) PangoMatrix font_matrix; PangoGravity gravity; FcMatrix fc_matrix, *fc_matrix_val; - double x, y; + double sx, sy, x, y, a, dx, dy; int i; ctm = pango_fc_font_key_get_matrix (key); @@ -974,15 +979,19 @@ 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.xy = fc_matrix.xy; + font_matrix.yx = fc_matrix.yx; font_matrix.yy = fc_matrix.yy; + font_matrix.x0 = 0; + font_matrix.y0 = 0; - pango_matrix_get_font_scale_factors (&font_matrix, &x, &y); + pango_matrix_decompose (&font_matrix, &sx, &sy, &x, &y, &a, &dx, &dy); x_scale_inv /= x; y_scale_inv /= y; + slant = sy; + gravity = pango_fc_font_key_get_gravity (key); if (PANGO_GRAVITY_IS_IMPROPER (gravity)) { @@ -1003,6 +1012,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); |