diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-05-09 01:31:58 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-05-09 01:31:58 +0000 |
commit | 4dcd060cc51c0ff954db365f06ac117d90c0443b (patch) | |
tree | 287afc250eabf5c188b3f8c4e8b42347acb9e159 /tests/test-font.c | |
parent | 73b46b04c724335ad73534cc69955baa2388b861 (diff) | |
parent | 5f2a5bbc95363ba25a6a7c107cd7daf260167e8b (diff) | |
download | pango-1-44.tar.gz |
Merge branch 'pango-1-44' into 'pango-1-44'pango-1-44
[1.44] Cherry pick various upstream fixes
See merge request GNOME/pango!321
Diffstat (limited to 'tests/test-font.c')
-rw-r--r-- | tests/test-font.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/test-font.c b/tests/test-font.c index 6b8f45be..dd110571 100644 --- a/tests/test-font.c +++ b/tests/test-font.c @@ -188,6 +188,73 @@ test_extents (void) g_object_unref (context); } +static void +test_roundtrip_plain (void) +{ + PangoFontMap *fontmap; + PangoContext *context; + PangoFontDescription *desc, *desc2; + PangoFont *font; + +#ifdef HAVE_CARBON + /* We probably don't have the right fonts */ + g_test_skip ("Skipping font-dependent tests on OS X"); + return; +#endif + + fontmap = pango_cairo_font_map_get_default (); + context = pango_font_map_create_context (fontmap); + + desc = pango_font_description_from_string ("Cantarell 11"); + + font = pango_context_load_font (context, desc); + desc2 = pango_font_describe (font); + + g_assert (pango_font_description_equal (desc2, desc)); + + pango_font_description_free (desc2); + g_object_unref (font); + pango_font_description_free (desc); + g_object_unref (context); +} + +static void +test_roundtrip_emoji (void) +{ + PangoFontMap *fontmap; + PangoContext *context; + PangoFontDescription *desc, *desc2; + PangoFont *font; + +#ifdef HAVE_CARBON + /* We probably don't have the right fonts */ + g_test_skip ("Skipping font-dependent tests on OS X"); + return; +#endif + + fontmap = pango_cairo_font_map_get_default (); + context = pango_font_map_create_context (fontmap); + + /* This is how pango_itemize creates the emoji font desc */ + desc = pango_font_description_from_string ("Cantarell 11"); + pango_font_description_set_family_static (desc, "emoji"); + + font = pango_context_load_font (context, desc); + desc2 = pango_font_describe (font); + + /* We can't expect the family name to match, since we go in with + * a generic family + */ + pango_font_description_unset_fields (desc, PANGO_FONT_MASK_FAMILY); + pango_font_description_unset_fields (desc2, PANGO_FONT_MASK_FAMILY); + g_assert (pango_font_description_equal (desc2, desc)); + + pango_font_description_free (desc2); + g_object_unref (font); + pango_font_description_free (desc); + g_object_unref (context); +} + int main (int argc, char *argv[]) { @@ -203,6 +270,8 @@ main (int argc, char *argv[]) g_test_add_func ("/pango/fontdescription/roundtrip", test_roundtrip); g_test_add_func ("/pango/fontdescription/variation", test_variation); g_test_add_func ("/pango/font/extents", test_extents); + g_test_add_func ("/pango/font/roundtrip/plain", test_roundtrip_plain); + g_test_add_func ("/pango/font/roundtrip/emoji", test_roundtrip_emoji); return g_test_run (); } |