diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-11-09 11:43:56 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-11-09 11:43:56 +0000 |
commit | ae90aa07e311d3a77936e2fdbf49111b92e8a69b (patch) | |
tree | 4f8c0f9c9bf87e0de591c6214d461cf7b8e8360c | |
parent | aae5fa3d34f021a3dcf8663d55f4fec19e9f7aff (diff) | |
parent | 4e9463108773bb9d45187efd61c6c395e0122187 (diff) | |
download | pango-ae90aa07e311d3a77936e2fdbf49111b92e8a69b.tar.gz |
Merge branch 'set-ptem' into 'main'
Call hb_font_set_ptem when creating fonts
See merge request GNOME/pango!498
-rw-r--r-- | pango/pangofc-font.c | 41 |
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) { |