gsk: Be safer against bad font options
Some combinations of hint-style and hint-metrics lead to bad glyph placement in the glyph cache, so avoid them.
This commit is contained in:
@@ -907,6 +907,7 @@ gsk_gpu_device_lookup_glyph_image (GskGpuDevice *self,
|
||||
gsize atlas_x, atlas_y, padding;
|
||||
float subpixel_x, subpixel_y;
|
||||
PangoFont *scaled_font;
|
||||
cairo_hint_metrics_t hint_metrics;
|
||||
|
||||
cache = g_hash_table_lookup (priv->glyph_cache, &lookup);
|
||||
if (cache)
|
||||
@@ -918,7 +919,15 @@ gsk_gpu_device_lookup_glyph_image (GskGpuDevice *self,
|
||||
return cache->image;
|
||||
}
|
||||
|
||||
scaled_font = gsk_reload_font (font, scale, CAIRO_HINT_METRICS_DEFAULT, CAIRO_HINT_STYLE_DEFAULT, CAIRO_ANTIALIAS_DEFAULT);
|
||||
/* The combination of hint-style != none and hint-metrics == off
|
||||
* leads to broken rendering with some fonts.
|
||||
*/
|
||||
if (gsk_font_get_hint_style (font) != CAIRO_HINT_STYLE_NONE)
|
||||
hint_metrics = CAIRO_HINT_METRICS_ON;
|
||||
else
|
||||
hint_metrics = CAIRO_HINT_METRICS_DEFAULT;
|
||||
|
||||
scaled_font = gsk_reload_font (font, scale, hint_metrics, CAIRO_HINT_STYLE_DEFAULT, CAIRO_ANTIALIAS_DEFAULT);
|
||||
|
||||
subpixel_x = (flags & 3) / 4.f;
|
||||
subpixel_y = ((flags >> 2) & 3) / 4.f;
|
||||
|
||||
Reference in New Issue
Block a user