diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-07-17 18:35:10 -0700 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-07-18 12:47:53 -0700 |
commit | 5048e7b0ce826997b34288b78e746e5e0dae2ea1 (patch) | |
tree | 414450d62e2dee92cee1b65f48e63b4c3d01f432 /tests | |
parent | fe3294ccf5a0b37c8a0950cc994ee0dfdd1dd909 (diff) | |
download | pango-5048e7b0ce826997b34288b78e746e5e0dae2ea1.tar.gz |
Add a very basic harfbuzz test
For now, just check that we get a non-NULL
hb_font_t that has a space glyph.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/meson.build | 1 | ||||
-rw-r--r-- | tests/test-harfbuzz.c | 68 |
2 files changed, 69 insertions, 0 deletions
diff --git a/tests/meson.build b/tests/meson.build index e1539299..c425665c 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -22,6 +22,7 @@ tests = [ [ 'testboundaries_ucd' ], [ 'testcolor' ], [ 'testscript' ], + [ 'test-harfbuzz', [ 'test-harfbuzz.c' ], [ libpangocairo_dep ] ], [ 'cxx-test', [ 'cxx-test.cpp' ], [ libpangocairo_dep ] ], [ 'test-break', [ 'test-break.c', 'test-common.c' ], [libpangocairo_dep ] ], ] diff --git a/tests/test-harfbuzz.c b/tests/test-harfbuzz.c new file mode 100644 index 00000000..f9392b67 --- /dev/null +++ b/tests/test-harfbuzz.c @@ -0,0 +1,68 @@ +/* Pango + * test-harfbuzz.c: Test Pango harfbuzz apis + * + * Copyright (C) 2019 Red Hat, Inc. + * + * 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 <pango/pango.h> +#include <pango/pangocairo.h> +#include "test-common.h" + +static PangoContext *context; + +/* Some basic checks that the hb_font_t returned + * by pango_font_get_hb_font is functional + */ +static void +test_hb_font (void) +{ + PangoFontDescription *desc; + PangoFont *font; + hb_font_t *hb_font; + hb_bool_t res; + hb_codepoint_t glyph; + + desc = pango_font_description_from_string ("Cantarell 11"); + font = pango_context_load_font (context, desc); + hb_font = pango_font_get_hb_font (font); + + g_assert (hb_font != NULL); + + res = hb_font_get_nominal_glyph (hb_font, 0x20, &glyph); + + g_assert (res); + g_assert (glyph != 0); + + g_object_unref (font); + pango_font_description_free (desc); +} + +int +main (int argc, char *argv[]) +{ + PangoFontMap *fontmap; + + fontmap = pango_cairo_font_map_get_default (); + context = pango_font_map_create_context (fontmap); + + g_test_init (&argc, &argv, NULL); + + g_test_add_func ("/harfbuzz/font", test_hb_font); + + return g_test_run (); +} |