1/* Pango
2 * test-harfbuzz.c: Test Pango harfbuzz apis
3 *
4 * Copyright (C) 2019 Red Hat, Inc.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22#include <pango/pango.h>
23#include <pango/pangocairo.h>
24#include "test-common.h"
25
26static PangoContext *context;
27
28/* Some basic checks that the hb_font_t returned
29 * by pango_font_get_hb_font is functional
30 */
31static void
32test_hb_font (void)
33{
34 PangoFontDescription *desc;
35 PangoFont *font;
36 hb_font_t *hb_font;
37 hb_bool_t res;
38 hb_codepoint_t glyph;
39
40 if (strcmp (G_OBJECT_TYPE_NAME (pango_context_get_font_map (context)), s2: "PangoCairoWin32FontMap") == 0)
41 desc = pango_font_description_from_string (str: "Verdana 11");
42 else
43 desc = pango_font_description_from_string (str: "Cantarell 11");
44 font = pango_context_load_font (context, desc);
45 hb_font = pango_font_get_hb_font (font);
46
47 g_assert (hb_font != NULL);
48
49 res = hb_font_get_nominal_glyph (font: hb_font, unicode: 0x20, glyph: &glyph);
50
51 g_assert (res);
52 g_assert (glyph != 0);
53
54 g_object_unref (object: font);
55 pango_font_description_free (desc);
56}
57
58int
59main (int argc, char *argv[])
60{
61 PangoFontMap *fontmap;
62
63 fontmap = pango_cairo_font_map_get_default ();
64 context = pango_font_map_create_context (fontmap);
65
66 g_test_init (argc: &argc, argv: &argv, NULL);
67
68 g_test_add_func (testpath: "/harfbuzz/font", test_func: test_hb_font);
69
70 return g_test_run ();
71}
72

source code of gtk/subprojects/pango/tests/test-harfbuzz.c