summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-11-08 20:06:47 -0500
committerMatthias Clasen <mclasen@redhat.com>2021-11-08 20:06:47 -0500
commit4e9463108773bb9d45187efd61c6c395e0122187 (patch)
tree4f8c0f9c9bf87e0de591c6214d461cf7b8e8360c
parentaae5fa3d34f021a3dcf8663d55f4fec19e9f7aff (diff)
downloadpango-set-ptem.tar.gz
Call hb_font_set_ptem when creating fontsset-ptem
This is useful information for Harfbuzz to have, so pass it along.
-rw-r--r--pango/pangofc-font.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index 79bc166f..824f5ab0 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -881,29 +881,25 @@ pango_fc_font_key_get_gravity (PangoFcFontKey *key)
return gravity;
}
-static double
-get_font_size (PangoFcFontKey *key)
+static void
+get_font_size (PangoFcFontKey *key,
+ double *pixel_size,
+ double *point_size)
{
const FcPattern *pattern;
- double size;
double dpi;
pattern = pango_fc_font_key_get_pattern (key);
- if (FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &size) == FcResultMatch)
- return size;
-
- /* Just in case FC_PIXEL_SIZE got unset between pango_fc_make_pattern()
- * and here. That would be very weird.
- */
+ if (FcPatternGetDouble (pattern, FC_SIZE, 0, point_size) != FcResultMatch)
+ *point_size = 13.;
- if (FcPatternGetDouble (pattern, FC_DPI, 0, &dpi) != FcResultMatch)
- dpi = 72;
-
- if (FcPatternGetDouble (pattern, FC_SIZE, 0, &size) == FcResultMatch)
- return size * dpi / 72.;
+ if (FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, pixel_size) != FcResultMatch)
+ {
+ if (FcPatternGetDouble (pattern, FC_DPI, 0, &dpi) != FcResultMatch)
+ dpi = 72.;
- /* Whatever */
- return 18.;
+ *pixel_size = *point_size * dpi / 72.;
+ }
}
static void
@@ -946,10 +942,12 @@ pango_fc_font_create_hb_font (PangoFont *font)
hb_font_t *hb_font;
double x_scale_inv, y_scale_inv;
double x_scale, y_scale;
- double size;
+ double pixel_size;
+ double point_size;
x_scale_inv = y_scale_inv = 1.0;
- size = 1.0;
+ pixel_size = 1.0;
+ point_size = 1.0;
key = _pango_fc_font_get_font_key (fc_font);
if (key)
@@ -984,7 +982,7 @@ pango_fc_font_create_hb_font (PangoFont *font)
x_scale_inv = -x_scale_inv;
y_scale_inv = -y_scale_inv;
}
- size = get_font_size (key);
+ get_font_size (key, &pixel_size, &point_size);
}
x_scale = 1. / x_scale_inv;
@@ -994,8 +992,9 @@ pango_fc_font_create_hb_font (PangoFont *font)
hb_font = hb_font_create (hb_face);
hb_font_set_scale (hb_font,
- size * PANGO_SCALE * x_scale,
- size * PANGO_SCALE * y_scale);
+ pixel_size * PANGO_SCALE * x_scale,
+ pixel_size * PANGO_SCALE * y_scale);
+ hb_font_set_ptem (hb_font, point_size);
if (key)
{