[pango/simple-fontmap: 30/31] testmisc: Add another test
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/simple-fontmap: 30/31] testmisc: Add another test
- Date: Sun, 26 Dec 2021 18:03:16 +0000 (UTC)
commit 1c2f4c9979a12e10bb81ce0c0908bf7f2adbb7da
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Dec 25 21:40:17 2021 -0500
testmisc: Add another test
tests/testmisc.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
---
diff --git a/tests/testmisc.c b/tests/testmisc.c
index e10491bd..80c2c89f 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -22,6 +22,7 @@
#include "config.h"
#include <glib.h>
#include <pango/pangocairo.h>
+#include <pango/pangofc-fontmap2.h>
#ifdef HAVE_CAIRO_FREETYPE
#include <pango/pango-ot.h>
@@ -1016,6 +1017,53 @@ test_hbfont_roundtrip (void)
g_free (path);
}
+static gboolean
+get_font (PangoFontset *fonts,
+ PangoFont *font,
+ gpointer data)
+{
+ gboolean *found = data;
+
+ PangoFontDescription *desc = pango_font_describe (font);
+ char *s = pango_font_description_to_string (desc);
+ g_print ("%s\n", s);
+ g_free (s);
+ pango_font_description_free (desc);
+
+ *found = TRUE;
+
+ return FALSE;
+}
+
+static void
+test_hbfont_language (void)
+{
+ PangoFontMap *map;
+ PangoContext *context;
+ PangoFontDescription *desc;
+ PangoFontset *fonts;
+ gboolean found;
+
+ map = PANGO_FONT_MAP (pango_fc_font_map2_new ());
+ context = pango_font_map_create_context (map);
+ desc = pango_font_description_from_string ("serif 11");
+
+ /* zz isn't assigned, so there should not be any fonts claiming to support
+ * this language. We are expecting to get a nonempty fontset regardless.
+ */
+ fonts = pango_font_map_load_fontset (map, context, desc, pango_language_from_string ("zz"));
+ g_assert_true (PANGO_IS_FONTSET (fonts));
+
+ found = FALSE;
+ pango_fontset_foreach (fonts, get_font, &found);
+ g_assert_true (found);
+
+ g_object_unref (fonts);
+ pango_font_description_free (desc);
+ g_object_unref (context);
+ g_object_unref (map);
+}
+
int
main (int argc, char *argv[])
{
@@ -1055,6 +1103,7 @@ main (int argc, char *argv[])
g_test_add_func ("/hbfont/monospace", test_hbfont_monospace);
g_test_add_func ("/hbface/roundtrip", test_hbface_roundtrip);
g_test_add_func ("/hbfont/roundtrip", test_hbfont_roundtrip);
+ g_test_add_func ("/hbfont/language", test_hbfont_language);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]