summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-01-24 11:15:01 -0500
committerMatthias Clasen <mclasen@redhat.com>2021-01-24 16:42:57 -0500
commitbc973fdb04b3f4b13c58738ed88c576c58df8b85 (patch)
treed2f2c7801e9848c7826e862a8c8929f023a3a906
parentafdd09716db2cf42dd1874c70993fac7f0722add (diff)
downloadpango-bc973fdb04b3f4b13c58738ed88c576c58df8b85.tar.gz
Fix pango_font_describe for Emoji fonts
We are using the size from the FcPattern. For scalable bitmap fonts, this has been scaled to match the requested pixel size. To make a font description that can be turned back into a FcPattern and roundtrip successfully, we need to undo that scaling. Thankfully, fontconfig leaves the pixelsizefixupfactor in the pattern, so it is easy to do. Fixes: #530
-rw-r--r--pango/pangofc-fontmap.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index 764336ae..fd17309d 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -2519,7 +2519,24 @@ pango_fc_font_description_from_pattern (FcPattern *pattern, gboolean include_siz
pango_font_description_set_variant (desc, PANGO_VARIANT_NORMAL);
if (include_size && FcPatternGetDouble (pattern, FC_SIZE, 0, &size) == FcResultMatch)
- pango_font_description_set_size (desc, size * PANGO_SCALE);
+ {
+ FcMatrix *fc_matrix;
+ double scale_factor = 1;
+
+ if (FcPatternGetMatrix (pattern, FC_MATRIX, 0, &fc_matrix) == FcResultMatch)
+ {
+ PangoMatrix mat = PANGO_MATRIX_INIT;
+
+ mat.xx = fc_matrix->xx;
+ mat.xy = fc_matrix->xy;
+ mat.yx = fc_matrix->yx;
+ mat.yy = fc_matrix->yy;
+
+ scale_factor = pango_matrix_get_font_scale_factor (&mat);
+ }
+
+ pango_font_description_set_size (desc, scale_factor * size * PANGO_SCALE);
+ }
/* gravity is a bit different. we don't want to set it if it was not set on
* the pattern */