From 775c99e5b8567d0a1773b6ffe6e6d2fd8047d097 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 28 Jul 2019 19:09:25 -0400 Subject: Take font matrix into account When setting up the scale of the hb_font_t, we need to take both the pango ctm and the font matrix into account - this used to come for free when we were calling into cairo for getting glyph metrics. Now, we use harfbuzz for glyph metrics, so we need to give it the proper scale info. The symptom of this was Emoji getting an enormous width. Curiously, cairo would still render them at the expected size. --- pango/pangofc-font.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c index 5ed9b792..a4bf5f61 100644 --- a/pango/pangofc-font.c +++ b/pango/pangofc-font.c @@ -1006,11 +1006,30 @@ pango_fc_font_create_hb_font (PangoFont *font) key = _pango_fc_font_get_font_key (fc_font); if (key) { + const FcPattern *pattern = pango_fc_font_key_get_pattern (key); const PangoMatrix *matrix; + PangoMatrix matrix2; PangoGravity gravity; + FcMatrix fc_matrix, *fc_matrix_val; + double x, y; + int i; matrix = pango_fc_font_key_get_matrix (key); pango_matrix_get_font_scale_factors (matrix, &x_scale_inv, &y_scale_inv); + + FcMatrixInit (&fc_matrix); + for (i = 0; FcPatternGetMatrix (pattern, FC_MATRIX, i, &fc_matrix_val) == FcResultMatch; i++) + FcMatrixMultiply (&fc_matrix, &fc_matrix, fc_matrix_val); + + matrix2.xx = fc_matrix.xx; + matrix2.yx = fc_matrix.yx; + matrix2.xy = fc_matrix.xy; + matrix2.yy = fc_matrix.yy; + pango_matrix_get_font_scale_factors (&matrix2, &x, &y); + + x_scale_inv /= x; + y_scale_inv /= y; + gravity = pango_fc_font_key_get_gravity (key); if (PANGO_GRAVITY_IS_IMPROPER (gravity)) { -- cgit v1.2.1