2 * Copyright © 2018 Google, Inc.
4 * This is part of HarfBuzz, a text shaping library.
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
31 /* Unit tests for hb-aat.h */
33 static hb_face_t *face;
34 static hb_face_t *sbix;
37 test_aat_get_feature_types (void)
39 hb_aat_layout_feature_type_t features[3];
40 unsigned int count = 3;
41 g_assert_cmpuint (11, ==, hb_aat_layout_get_feature_types (face, 0, &count, features));
43 g_assert_cmpuint (1, ==, features[0]);
44 g_assert_cmpuint (3, ==, features[1]);
45 g_assert_cmpuint (6, ==, features[2]);
47 g_assert_cmpuint (258, ==, hb_aat_layout_feature_type_get_name_id (face, features[0]));
48 g_assert_cmpuint (261, ==, hb_aat_layout_feature_type_get_name_id (face, features[1]));
49 g_assert_cmpuint (265, ==, hb_aat_layout_feature_type_get_name_id (face, features[2]));
53 test_aat_get_feature_selectors (void)
55 unsigned int default_index;
56 hb_aat_layout_feature_selector_info_t settings[3];
57 unsigned int count = 3;
59 g_assert_cmpuint (4, ==, hb_aat_layout_feature_type_get_selector_infos (face,
60 HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE,
63 g_assert_cmpuint (3, ==, count);
64 g_assert_cmpuint (0, ==, default_index);
66 g_assert_cmpuint (0, ==, settings[0].enable);
67 g_assert_cmpuint (294, ==, settings[0].name_id);
69 g_assert_cmpuint (1, ==, settings[1].enable);
70 g_assert_cmpuint (295, ==, settings[1].name_id);
72 g_assert_cmpuint (2, ==, settings[2].enable);
73 g_assert_cmpuint (296, ==, settings[2].name_id);
76 g_assert_cmpuint (4, ==, hb_aat_layout_feature_type_get_selector_infos (face,
77 HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE,
80 g_assert_cmpuint (1, ==, count);
81 g_assert_cmpuint (0, ==, default_index);
83 g_assert_cmpuint (3, ==, settings[0].enable);
84 g_assert_cmpuint (297, ==, settings[0].name_id);
87 g_assert_cmpuint (1, ==, hb_aat_layout_feature_type_get_selector_infos (face,
88 HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS,
91 g_assert_cmpuint (1, ==, count);
92 g_assert_cmpuint (HB_AAT_LAYOUT_NO_SELECTOR_INDEX, ==, default_index);
94 g_assert_cmpuint (8, ==, settings[0].enable);
95 g_assert_cmpuint (308, ==, settings[0].name_id);
98 g_assert_cmpuint (0, ==, hb_aat_layout_feature_type_get_selector_infos (face, HB_AAT_LAYOUT_FEATURE_TYPE_INVALID,
101 g_assert_cmpuint (0, ==, count);
107 hb_face_t *morx = hb_test_open_font_file ("fonts/aat-morx.ttf");
109 g_assert (hb_aat_layout_has_substitution (morx));
110 hb_face_destroy (morx);
112 trak = hb_test_open_font_file ("fonts/aat-trak.ttf");
113 g_assert (hb_aat_layout_has_tracking (trak));
114 hb_face_destroy (trak);
118 main (int argc, char **argv)
121 hb_test_init (&argc, &argv);
123 hb_test_add (test_aat_get_feature_types);
124 hb_test_add (test_aat_get_feature_selectors);
125 hb_test_add (test_aat_has);
127 face = hb_test_open_font_file ("fonts/aat-feat.ttf");
128 sbix = hb_test_open_font_file ("fonts/chromacheck-sbix.ttf");
129 status = hb_test_run ();
130 hb_face_destroy (sbix);
131 hb_face_destroy (face);