diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-10-28 02:34:40 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-10-28 02:34:40 +0000 |
commit | 522101fa2b3dd6a950f1bd289fcca51fd7de8833 (patch) | |
tree | 69851c64fbb4603417243355a8321b9e90acc5da | |
parent | 64180fcba8d534c4aa831ce906ddb7cd137ec6d8 (diff) | |
parent | 7a4af7a052e7e4187955aad9c4c60853bad806f9 (diff) | |
download | pango-522101fa2b3dd6a950f1bd289fcca51fd7de8833.tar.gz |
Merge branch 'gravity-metrics-fix' into 'main'
Revert "Use harfbuzz metrics for cairo fonts"
See merge request GNOME/pango!487
-rw-r--r-- | pango/pangocairo-font.c | 43 | ||||
-rw-r--r-- | tests/testmisc.c | 14 |
2 files changed, 30 insertions, 27 deletions
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c index 15c5be4a..69c375c3 100644 --- a/pango/pangocairo-font.c +++ b/pango/pangocairo-font.c @@ -784,41 +784,40 @@ struct _PangoCairoFontGlyphExtentsCacheEntry static gboolean _pango_cairo_font_private_glyph_extents_cache_init (PangoCairoFontPrivate *cf_priv) { - PangoCairoFont *cfont = cf_priv->cfont; - PangoFontMetrics *metrics = _pango_cairo_font_get_metrics (PANGO_FONT (cfont), NULL); + cairo_scaled_font_t *scaled_font = _pango_cairo_font_private_get_scaled_font (cf_priv); + cairo_font_extents_t font_extents; + + if (G_UNLIKELY (scaled_font == NULL || cairo_scaled_font_status (scaled_font) != CAIRO_STATUS_SUCCESS)) + return FALSE; + + cairo_scaled_font_extents (scaled_font, &font_extents); cf_priv->font_extents.x = 0; cf_priv->font_extents.width = 0; - cf_priv->font_extents.height = metrics->ascent + metrics->descent; - + cf_priv->font_extents.height = pango_units_from_double (font_extents.ascent + font_extents.descent); switch (cf_priv->gravity) { default: case PANGO_GRAVITY_AUTO: case PANGO_GRAVITY_SOUTH: - cf_priv->font_extents.y = - metrics->ascent; - break; + cf_priv->font_extents.y = - pango_units_from_double (font_extents.ascent); + break; case PANGO_GRAVITY_NORTH: - cf_priv->font_extents.y = - metrics->descent; - break; + cf_priv->font_extents.y = - pango_units_from_double (font_extents.descent); + break; case PANGO_GRAVITY_EAST: case PANGO_GRAVITY_WEST: - { - int ascent = (metrics->ascent + metrics->descent) / 2; - if (cf_priv->is_hinted) - ascent = PANGO_UNITS_ROUND (ascent); - cf_priv->font_extents.y = - ascent; - } + { + int ascent = pango_units_from_double (font_extents.ascent + font_extents.descent) / 2; + if (cf_priv->is_hinted) + ascent = PANGO_UNITS_ROUND (ascent); + cf_priv->font_extents.y = - ascent; + } } - pango_font_metrics_unref (metrics); - - if (!cf_priv->glyph_extents_cache) - { - cf_priv->glyph_extents_cache = g_new0 (PangoCairoFontGlyphExtentsCacheEntry, GLYPH_CACHE_NUM_ENTRIES); - /* Make sure all cache entries are invalid initially */ - cf_priv->glyph_extents_cache[0].glyph = 1; /* glyph 1 cannot happen in bucket 0 */ - } + cf_priv->glyph_extents_cache = g_new0 (PangoCairoFontGlyphExtentsCacheEntry, GLYPH_CACHE_NUM_ENTRIES); + /* Make sure all cache entries are invalid initially */ + cf_priv->glyph_extents_cache[0].glyph = 1; /* glyph 1 cannot happen in bucket 0 */ return TRUE; } diff --git a/tests/testmisc.c b/tests/testmisc.c index b9ec81ea..85a3b0b5 100644 --- a/tests/testmisc.c +++ b/tests/testmisc.c @@ -125,6 +125,9 @@ test_line_height (void) g_object_unref (context); } +#if 0 +/* These tests fail since I had to revert 20ec670e124e446107 + */ static void test_line_height2 (void) { @@ -252,6 +255,7 @@ test_cursor_height2 (void) g_object_unref (layout); g_object_unref (context); } +#endif static void test_attr_list_update (void) @@ -668,11 +672,11 @@ main (int argc, char *argv[]) g_test_add_func ("/layout/short-string-crash", test_short_string_crash); g_test_add_func ("/language/emoji-crash", test_language_emoji_crash); g_test_add_func ("/layout/line-height", test_line_height); - g_test_add_func ("/layout/line-height2", test_line_height2); - g_test_add_func ("/layout/line-height3", test_line_height3); - g_test_add_func ("/layout/run-height", test_run_height); - g_test_add_func ("/layout/cursor-height", test_cursor_height); - g_test_add_func ("/layout/cursor-height2", test_cursor_height2); + //g_test_add_func ("/layout/line-height2", test_line_height2); + //g_test_add_func ("/layout/line-height3", test_line_height3); + //g_test_add_func ("/layout/run-height", test_run_height); + //g_test_add_func ("/layout/cursor-height", test_cursor_height); + //g_test_add_func ("/layout/cursor-height2", test_cursor_height2); g_test_add_func ("/attr-list/update", test_attr_list_update); g_test_add_func ("/misc/version-info", test_version_info); g_test_add_func ("/misc/is-zerowidth", test_is_zero_width); |