From 41d718553a1358661e58ca7915b59f958e780600 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 30 Dec 2021 12:26:06 -0500 Subject: Add some useful face api Add pango_font_face_supports_language and pango_font_face_get_languages. There is no particular reason to tie language information to fonts instead of faces. This will be useful for the font chooser. Update the fontconfig implementation for these changes. --- tests/test-font.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tests') diff --git a/tests/test-font.c b/tests/test-font.c index 2fa54cdf..8dd540f4 100644 --- a/tests/test-font.c +++ b/tests/test-font.c @@ -564,6 +564,42 @@ test_match (void) pango_font_description_free (desc2); } +static void +test_font_languages (void) +{ + PangoFontMap *fontmap; + PangoContext *context; + PangoFontDescription *desc; + PangoFont *font; + PangoFontFace *face; + PangoLanguage **languages; + +#ifdef HAVE_CARBON + desc = pango_font_description_from_string ("Helvetica 11"); +#else + desc = pango_font_description_from_string ("Cantarell 11"); +#endif + + fontmap = pango_cairo_font_map_get_default (); + context = pango_font_map_create_context (fontmap); + + font = pango_context_load_font (context, desc); + + languages = pango_font_get_languages (font); + g_assert_nonnull (languages); + g_assert_nonnull (languages[0]); + + face = pango_font_get_face (font); + languages = pango_font_face_get_languages (face); + g_assert_nonnull (languages); + g_assert_nonnull (languages[0]); + g_assert_true (pango_font_face_supports_language (face, languages[0])); + + g_object_unref (font); + pango_font_description_free (desc); + g_object_unref (context); +} + int main (int argc, char *argv[]) { @@ -589,6 +625,7 @@ main (int argc, char *argv[]) g_test_add_func ("/pango/font/models", test_font_models); g_test_add_func ("/pango/font/glyph-extents", test_glyph_extents); g_test_add_func ("/pango/font/font-metrics", test_font_metrics); + g_test_add_func ("/pango/font/languages", test_font_languages); return g_test_run (); } -- cgit v1.2.1