[pango/simple-fontmap: 15/23] Add a PangoFcHbFontMap test
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/simple-fontmap: 15/23] Add a PangoFcHbFontMap test
- Date: Fri, 31 Dec 2021 20:31:23 +0000 (UTC)
commit 66601bd901a9cd5ea8d63d2a2c78293828cf3a49
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Dec 31 15:16:50 2021 -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 28dd5c70..6fba6f7e 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]