diff options
author | John Ralls <jralls@ceridwen.us> | 2018-04-29 16:03:08 -0700 |
---|---|---|
committer | John Ralls <jralls@ceridwen.us> | 2018-05-08 17:55:35 -0700 |
commit | f661cdbf8cfbdb2ba7241d8dfa4a579c6dfe0a94 (patch) | |
tree | ee57d3ef3507c65bd5a74c13ad10f63cb4c72964 /pango | |
parent | edb0dff3454d4d9ce6242a0f30ddaef993ee1e89 (diff) | |
download | pango-f661cdbf8cfbdb2ba7241d8dfa4a579c6dfe0a94.tar.gz |
Restore scaling of CoreText fonts.
Fixes bug 787867.
Diffstat (limited to 'pango')
-rw-r--r-- | pango/pangocairo-coretextfont.c | 17 | ||||
-rw-r--r-- | pango/pangocairo-coretextfontmap.c | 2 | ||||
-rw-r--r-- | pango/pangocoretext-fontmap.c | 15 | ||||
-rw-r--r-- | pango/pangocoretext-private.h | 2 | ||||
-rw-r--r-- | pango/pangocoretext.c | 5 |
5 files changed, 32 insertions, 9 deletions
diff --git a/pango/pangocairo-coretextfont.c b/pango/pangocairo-coretextfont.c index c07f1c77..9dc33447 100644 --- a/pango/pangocairo-coretextfont.c +++ b/pango/pangocairo-coretextfont.c @@ -36,6 +36,7 @@ struct _PangoCairoCoreTextFont { PangoCoreTextFont font; PangoCairoFontPrivate cf_priv; + int abs_size; }; struct _PangoCairoCoreTextFontClass @@ -162,6 +163,17 @@ pango_cairo_core_text_font_create_base_metrics_for_context (PangoCairoFont *font return metrics; } +static PangoFontDescription * +pango_cairo_core_text_font_describe_absolute (PangoFont *font) +{ + PangoCairoCoreTextFont *cafont = (PangoCairoCoreTextFont *)font; + PangoFontDescription *desc = pango_font_describe (font); + + pango_font_description_set_absolute_size (desc, cafont->abs_size); + + return desc; +} + static void pango_cairo_core_text_font_finalize (GObject *object) { @@ -179,9 +191,10 @@ pango_cairo_core_text_font_class_init (PangoCairoCoreTextFontClass *class) PangoFontClass *font_class = PANGO_FONT_CLASS (class); object_class->finalize = pango_cairo_core_text_font_finalize; - + /* font_class->describe defined by parent class PangoCoreTextFont. */ font_class->get_glyph_extents = pango_cairo_core_text_font_get_glyph_extents; font_class->get_metrics = _pango_cairo_font_get_metrics; + font_class->describe_absolute = pango_cairo_core_text_font_describe_absolute; } static void @@ -219,6 +232,8 @@ _pango_cairo_core_text_font_new (PangoCairoCoreTextFontMap *cafontmap, cafont = g_object_new (PANGO_TYPE_CAIRO_CORE_TEXT_FONT, NULL); cfont = PANGO_CORE_TEXT_FONT (cafont); + cafont->abs_size = pango_core_text_font_key_get_size (key); + _pango_core_text_font_set_ctfont (cfont, font_ref); if (synthesize_italic) diff --git a/pango/pangocairo-coretextfontmap.c b/pango/pangocairo-coretextfontmap.c index ba5dcec0..5054b7a8 100644 --- a/pango/pangocairo-coretextfontmap.c +++ b/pango/pangocairo-coretextfontmap.c @@ -186,5 +186,5 @@ static void pango_cairo_core_text_font_map_init (PangoCairoCoreTextFontMap *cafontmap) { cafontmap->serial = 1; - cafontmap->dpi = 72.; + cafontmap->dpi = 96.; } diff --git a/pango/pangocoretext-fontmap.c b/pango/pangocoretext-fontmap.c index 4d101847..c5cacab4 100644 --- a/pango/pangocoretext-fontmap.c +++ b/pango/pangocoretext-fontmap.c @@ -806,6 +806,7 @@ get_context_matrix (PangoContext *context, /* * Helper functions for PangoCoreTextFontsetKey */ +static const double ppi = 72.0; /* typographic points per inch */ static double pango_core_text_font_map_get_resolution (PangoCoreTextFontMap *fontmap, @@ -817,7 +818,7 @@ pango_core_text_font_map_get_resolution (PangoCoreTextFontMap *fontmap, /* FIXME: acquire DPI from CoreText using some deafault font */ g_warning ("FIXME: returning default DPI"); - return 72.0; + return ppi; } static int @@ -826,8 +827,16 @@ get_scaled_size (PangoCoreTextFontMap *fontmap, const PangoFontDescription *desc) { double size = pango_font_description_get_size (desc); - - return .5 + pango_matrix_get_font_scale_factor (pango_context_get_matrix (context)) * size; + PangoMatrix *matrix = pango_context_get_matrix (context); + double scale_factor = pango_matrix_get_font_scale_factor (matrix); + + if (!pango_font_description_get_size_is_absolute(desc)) + { + double dpi = pango_core_text_font_map_get_resolution (fontmap, context); + size *= (dpi/ppi); + } + + return .5 + scale_factor * size; } diff --git a/pango/pangocoretext-private.h b/pango/pangocoretext-private.h index c6c642cd..76eb1ebc 100644 --- a/pango/pangocoretext-private.h +++ b/pango/pangocoretext-private.h @@ -99,6 +99,8 @@ void _pango_core_text_font_set_ctfont (PangoCoreTextF PangoFontDescription *_pango_core_text_font_description_from_ct_font_descriptor (CTFontDescriptorRef desc); _PANGO_EXTERN +int pango_core_text_font_key_get_size (const PangoCoreTextFontKey *key); +_PANGO_EXTERN int pango_core_text_font_key_get_size (const PangoCoreTextFontKey *key); _PANGO_EXTERN double pango_core_text_font_key_get_resolution (const PangoCoreTextFontKey *key); diff --git a/pango/pangocoretext.c b/pango/pangocoretext.c index 8cba1aae..2aa1810a 100644 --- a/pango/pangocoretext.c +++ b/pango/pangocoretext.c @@ -225,10 +225,7 @@ pango_core_text_font_class_init (PangoCoreTextFontClass *class) object_class->finalize = pango_core_text_font_finalize; font_class->describe = pango_core_text_font_describe; - /* In CoreText the device unit is points so describe_absoulute and - * describe are the same. - */ - font_class->describe_absolute = pango_core_text_font_describe; + /* font_class->describe_absolute is left virtual for PangoCairoCoreTextFont. */ font_class->get_coverage = pango_core_text_font_get_coverage; font_class->find_shaper = pango_core_text_font_find_shaper; font_class->get_font_map = pango_core_text_font_get_font_map; |