[pango/simple-fontmap: 5/16] Add a test for PangoHbFace getters




commit 94350a65ac765fcf4d5432deef39c7aa39813352
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Oct 31 19:48:52 2021 -0400

    Add a test for PangoHbFace getters
    
    Test that is_variable() and is_monospace() work
    as expected for PangoHbFace.

 tests/meson.build  |  1 +
 tests/testhbfont.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+)
---
diff --git a/tests/meson.build b/tests/meson.build
index b885f999..54bd5c13 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -57,6 +57,7 @@ if cairo_dep.found()
     tests += [
       [ 'testmisc', [ 'testmisc.c' ], [ libpangocairo_dep, libpangoft2_dep, glib_dep, harfbuzz_dep ] ],
       [ 'testserialize', [ 'testserialize.c' ], [ libpangocairo_dep, libpangoft2_dep ] ],
+      [ 'testhbfont', [ 'testhbfont.c' ], [ libpangocairo_dep, libpangoft2_dep, glib_dep, harfbuzz_dep ] ],
     ]
 
     if host_system != 'darwin'
diff --git a/tests/testhbfont.c b/tests/testhbfont.c
new file mode 100644
index 00000000..28bc6ddd
--- /dev/null
+++ b/tests/testhbfont.c
@@ -0,0 +1,76 @@
+/* Pango
+ * testhbfont.c: Test program for PangoHbFont etc
+ *
+ * Copyright (C) 2021 Matthias Clasen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+#include <glib.h>
+#include <pango/pangocairo.h>
+
+#include <pango/pangofc-fontmap2.h>
+
+#ifdef HAVE_CAIRO_FREETYPE
+#include <pango/pango-ot.h>
+#endif
+
+
+/* Verify that the variable and monospace properties work as expected
+ * for PangoHbFamily
+ */
+static void
+test_hbfont_monospace (void)
+{
+  PangoHbFontMap *map;
+  PangoFontFamily *family;
+  char *path;
+
+  map = pango_hb_font_map_new ();
+
+  path = g_test_build_filename (G_TEST_DIST, "fonts", "Cantarell-VF.otf", NULL);
+  pango_hb_font_map_add_file (map, path);
+  g_free (path);
+
+  family = pango_font_map_get_family (PANGO_FONT_MAP (map), "Cantarell");
+
+  g_assert_nonnull (family);
+  g_assert_true (pango_font_family_is_variable (family));
+  g_assert_false (pango_font_family_is_monospace (family));
+
+  path = g_test_build_filename (G_TEST_DIST, "fonts", "DejaVuSansMono.ttf", NULL);
+  pango_hb_font_map_add_file (map, path);
+  g_free (path);
+
+  family = pango_font_map_get_family (PANGO_FONT_MAP (map), "DejaVu Sans Mono");
+
+  g_assert_nonnull (family);
+  g_assert_false (pango_font_family_is_variable (family));
+  g_assert_true (pango_font_family_is_monospace (family));
+
+  g_object_unref (map);
+}
+
+int
+main (int argc, char *argv[])
+{
+  g_test_init (&argc, &argv, NULL);
+
+  g_test_add_func ("/hbfont/monospace", test_hbfont_monospace);
+
+  return g_test_run ();
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]