[pango/simple-fontmap: 30/35] Add a PangoFcHbFontMap test
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/simple-fontmap: 30/35] Add a PangoFcHbFontMap test
- Date: Tue, 4 Jan 2022 14:17:54 +0000 (UTC)
commit 21df78120d593ba5ed6b16f58b0fa48b028c81b3
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jan 1 17:44:46 2022 -0500
Add a PangoFcHbFontMap test
tests/testhbfont.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
---
diff --git a/tests/testhbfont.c b/tests/testhbfont.c
index beaf0d88..2ffb2f38 100644
--- a/tests/testhbfont.c
+++ b/tests/testhbfont.c
@@ -22,6 +22,7 @@
#include "config.h"
#include <glib.h>
#include <pango/pangocairo.h>
+#include <pango/pangofc-hbfontmap.h>
#ifdef HAVE_CAIRO_FREETYPE
#include <pango/pango-ot.h>
@@ -222,6 +223,51 @@ test_hbfont_describe (void)
g_free (path);
}
+/* Verify that pango_fontmap_load_fontset produces a non-empty result
+ * even if the language isn't covered - our itemization code relies
+ * on this.
+ */
+static gboolean
+get_font (PangoFontset *fontset,
+ PangoFont *font,
+ gpointer data)
+{
+ gboolean *found = data;
+
+ *found = TRUE;
+
+ return TRUE;
+}
+
+static void
+test_hbfont_language (void)
+{
+ PangoFontMap *map;
+ PangoContext *context;
+ PangoFontDescription *desc;
+ PangoFontset *fonts;
+ gboolean found;
+
+ map = PANGO_FONT_MAP (pango_fc_hb_font_map_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[])
{
@@ -231,6 +277,7 @@ main (int argc, char *argv[])
g_test_add_func ("/hbface/roundtrip", test_hbface_roundtrip);
g_test_add_func ("/hbfont/roundtrip", test_hbfont_roundtrip);
g_test_add_func ("/hbfont/describe", test_hbfont_describe);
+ 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]