[pango/fix-emoji-scaling] Take font matrix into account
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/fix-emoji-scaling] Take font matrix into account
- Date: Sun, 28 Jul 2019 23:11:47 +0000 (UTC)
commit 775c99e5b8567d0a1773b6ffe6e6d2fd8047d097
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jul 28 19:09:25 2019 -0400
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))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]