Imported Upstream version 2.3.1
[platform/upstream/harfbuzz.git] / test / api / test-ot-color.c
1 /*
2  * Copyright © 2016  Google, Inc.
3  * Copyright © 2018  Ebrahim Byagowi
4  *
5  *  This is part of HarfBuzz, a text shaping library.
6  *
7  * Permission is hereby granted, without written agreement and without
8  * license or royalty fees, to use, copy, modify, and distribute this
9  * software and its documentation for any purpose, provided that the
10  * above copyright notice and the following two paragraphs appear in
11  * all copies of this software.
12  *
13  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17  * DAMAGE.
18  *
19  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
22  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24  *
25  * Google Author(s): Sascha Brawer
26  */
27
28 #include "hb-test.h"
29
30 #include <hb-ot.h>
31
32 /* Unit tests for hb-ot-color.h */
33
34 /* Test font with the following CPAL v0 table, as TTX and manual disassembly:
35
36   <CPAL>
37     <version value="0"/>
38     <numPaletteEntries value="2"/>
39     <palette index="0">
40       <color index="0" value="#000000FF"/>
41       <color index="1" value="#66CCFFFF"/>
42     </palette>
43     <palette index="1">
44       <color index="0" value="#000000FF"/>
45       <color index="1" value="#800000FF"/>
46     </palette>
47   </CPAL>
48
49    0 | 0000                           # version=0
50    2 | 0002                           # numPaletteEntries=2
51    4 | 0002                           # numPalettes=2
52    6 | 0004                           # numColorRecords=4
53    8 | 00000010                       # offsetToFirstColorRecord=16
54   12 | 0000 0002                      # colorRecordIndex=[0, 2]
55   16 | 000000ff ffcc66ff              # colorRecord #0, #1 (BGRA)
56   24 | 000000ff 000080ff              # colorRecord #2, #3 (BGRA)
57  */
58 static hb_face_t *cpal_v0 = NULL;
59
60 /* Test font with the following CPAL v1 table, as TTX and manual disassembly:
61
62   <CPAL>
63     <version value="1"/>
64     <numPaletteEntries value="2"/>
65     <palette index="0" label="257" type="2">
66       <color index="0" value="#000000FF"/>
67       <color index="1" value="#66CCFFFF"/>
68     </palette>
69     <palette index="1" label="65535" type="1">
70       <color index="0" value="#000000FF"/>
71       <color index="1" value="#FFCC66FF"/>
72     </palette>
73     <palette index="2" label="258" type="0">
74       <color index="0" value="#000000FF"/>
75       <color index="1" value="#800000FF"/>
76     </palette>
77     <paletteEntryLabels>
78       <label index="0" value="65535"/>
79       <label index="1" value="256"/>
80     </paletteEntryLabels>
81   </CPAL>
82
83    0 | 0001                           # version=1
84    2 | 0002                           # numPaletteEntries=2
85    4 | 0003                           # numPalettes=3
86    6 | 0006                           # numColorRecords=6
87    8 | 0000001e                       # offsetToFirstColorRecord=30
88   12 | 0000 0002 0004                 # colorRecordIndex=[0, 2, 4]
89   18 | 00000036                       # offsetToPaletteTypeArray=54
90   22 | 00000042                       # offsetToPaletteLabelArray=66
91   26 | 00000048                       # offsetToPaletteEntryLabelArray=72
92   30 | 000000ff ffcc66ff 000000ff     # colorRecord #0, #1, #2 (BGRA)
93   42 | 66ccffff 000000ff 000080ff     # colorRecord #3, #4, #5 (BGRA)
94   54 | 00000002 00000001 00000000     # paletteFlags=[2, 1, 0]
95   66 | 0101 ffff 0102                 # paletteName=[257, 0xffff, 258]
96   72 | ffff 0100                      # paletteEntryLabel=[0xffff, 256]
97 */
98 static hb_face_t *cpal_v1 = NULL;
99
100 static hb_face_t *cpal = NULL;
101 static hb_face_t *cbdt = NULL;
102 static hb_face_t *sbix = NULL;
103 static hb_face_t *svg = NULL;
104 static hb_face_t *empty = NULL;
105
106 #define assert_color_rgba(colors, i, r, g, b, a) G_STMT_START { \
107   const hb_color_t *_colors = (colors); \
108   const size_t _i = (i); \
109   const uint8_t red = (r), green = (g), blue = (b), alpha = (a); \
110   if (hb_color_get_red (_colors[_i]) != red) { \
111     g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
112                                 "colors[" #i "]", _colors[_i], "==", red, 'x'); \
113   } \
114   if (hb_color_get_green (_colors[_i]) != green) { \
115     g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
116                                 "colors[" #i "]", _colors[_i], "==", green, 'x'); \
117   } \
118   if (hb_color_get_blue (_colors[_i]) != blue) { \
119     g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
120                                 "colors[" #i "]", colors[_i], "==", blue, 'x'); \
121   } \
122   if (hb_color_get_alpha (_colors[_i]) != alpha) { \
123     g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
124                                 "colors[" #i "]", _colors[_i], "==", alpha, 'x'); \
125   } \
126 } G_STMT_END
127
128
129 static void
130 test_hb_ot_color_palette_get_count (void)
131 {
132   g_assert_cmpint (hb_ot_color_palette_get_count (hb_face_get_empty()), ==, 0);
133   g_assert_cmpint (hb_ot_color_palette_get_count (cpal_v0), ==, 2);
134   g_assert_cmpint (hb_ot_color_palette_get_count (cpal_v1), ==, 3);
135 }
136
137
138 static void
139 test_hb_ot_color_palette_get_name_id_empty (void)
140 {
141   /* numPalettes=0, so all calls are for out-of-bounds palette indices */
142   g_assert_cmpint (hb_ot_color_palette_get_name_id (hb_face_get_empty(), 0), ==, HB_OT_NAME_ID_INVALID);
143   g_assert_cmpint (hb_ot_color_palette_get_name_id (hb_face_get_empty(), 1), ==, HB_OT_NAME_ID_INVALID);
144 }
145
146
147 static void
148 test_hb_ot_color_palette_get_name_id_v0 (void)
149 {
150   g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v0, 0), ==, HB_OT_NAME_ID_INVALID);
151   g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v0, 1), ==, HB_OT_NAME_ID_INVALID);
152
153   /* numPalettes=2, so palette #2 is out of bounds */
154   g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v0, 2), ==, HB_OT_NAME_ID_INVALID);
155 }
156
157
158 static void
159 test_hb_ot_color_palette_get_name_id_v1 (void)
160 {
161   g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v1, 0), ==, 257);
162   g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v1, 1), ==, HB_OT_NAME_ID_INVALID);
163   g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v1, 2), ==, 258);
164
165   /* numPalettes=3, so palette #3 is out of bounds */
166   g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v1, 3), ==, HB_OT_NAME_ID_INVALID);
167 }
168
169
170 static void
171 test_hb_ot_color_palette_get_flags_empty (void)
172 {
173   /* numPalettes=0, so all calls are for out-of-bounds palette indices */
174   g_assert_cmpint (hb_ot_color_palette_get_flags (hb_face_get_empty(), 0), ==, HB_OT_COLOR_PALETTE_FLAG_DEFAULT);
175   g_assert_cmpint (hb_ot_color_palette_get_flags (hb_face_get_empty(), 1), ==, HB_OT_COLOR_PALETTE_FLAG_DEFAULT);
176 }
177
178
179 static void
180 test_hb_ot_color_palette_get_flags_v0 (void)
181 {
182   g_assert_cmpint (hb_ot_color_palette_get_flags (cpal_v0, 0), ==, HB_OT_COLOR_PALETTE_FLAG_DEFAULT);
183   g_assert_cmpint (hb_ot_color_palette_get_flags (cpal_v0, 1), ==, HB_OT_COLOR_PALETTE_FLAG_DEFAULT);
184
185   /* numPalettes=2, so palette #2 is out of bounds */
186   g_assert_cmpint (hb_ot_color_palette_get_flags (cpal_v0, 2), ==, HB_OT_COLOR_PALETTE_FLAG_DEFAULT);
187 }
188
189
190 static void
191 test_hb_ot_color_palette_get_flags_v1 (void)
192 {
193   g_assert_cmpint (hb_ot_color_palette_get_flags (cpal_v1, 0), ==, HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_DARK_BACKGROUND);
194   g_assert_cmpint (hb_ot_color_palette_get_flags (cpal_v1, 1), ==, HB_OT_COLOR_PALETTE_FLAG_USABLE_WITH_LIGHT_BACKGROUND);
195   g_assert_cmpint (hb_ot_color_palette_get_flags (cpal_v0, 2), ==, HB_OT_COLOR_PALETTE_FLAG_DEFAULT);
196
197   /* numPalettes=3, so palette #3 is out of bounds */
198   g_assert_cmpint (hb_ot_color_palette_get_flags (cpal_v0, 3), ==, HB_OT_COLOR_PALETTE_FLAG_DEFAULT);
199 }
200
201
202 static void
203 test_hb_ot_color_palette_get_colors_empty (void)
204 {
205   g_assert_cmpint (hb_ot_color_palette_get_colors (empty, 0, 0, NULL, NULL), ==, 0);
206 }
207
208
209 static void
210 test_hb_ot_color_palette_get_colors_v0 (void)
211 {
212   unsigned int num_colors = hb_ot_color_palette_get_colors (cpal_v0, 0, 0, NULL, NULL);
213   hb_color_t *colors = (hb_color_t*) alloca (num_colors * sizeof (hb_color_t));
214   size_t colors_size = num_colors * sizeof(*colors);
215   g_assert_cmpint (num_colors, ==, 2);
216
217   /* Palette #0, start_index=0 */
218   g_assert_cmpint (hb_ot_color_palette_get_colors (cpal_v0, 0, 0, &num_colors, colors), ==, 2);
219   g_assert_cmpint (num_colors, ==, 2);
220   assert_color_rgba (colors, 0, 0x00, 0x00, 0x00, 0xff);
221   assert_color_rgba (colors, 1, 0x66, 0xcc, 0xff, 0xff);
222
223   /* Palette #1, start_index=0 */
224   g_assert_cmpint (hb_ot_color_palette_get_colors (cpal_v0, 1, 0, &num_colors, colors), ==, 2);
225   g_assert_cmpint (num_colors, ==, 2);
226   assert_color_rgba (colors, 0, 0x00, 0x00, 0x00, 0xff);
227   assert_color_rgba (colors, 1, 0x80, 0x00, 0x00, 0xff);
228
229   /* Palette #2 (there are only #0 and #1 in the font, so this is out of bounds) */
230   g_assert_cmpint (hb_ot_color_palette_get_colors (cpal_v0, 2, 0, &num_colors, colors), ==, 0);
231
232   /* Palette #0, start_index=1 */
233   memset(colors, 0x33, colors_size);
234   num_colors = 2;
235   g_assert_cmpint (hb_ot_color_palette_get_colors (cpal_v0, 0, 1, &num_colors, colors), ==, 2);
236   g_assert_cmpint (num_colors, ==, 1);
237   assert_color_rgba (colors, 0, 0x66, 0xcc, 0xff, 0xff);
238   assert_color_rgba (colors, 1, 0x33, 0x33, 0x33, 0x33);  /* untouched */
239
240   /* Palette #0, start_index=0, pretend that we have only allocated space for 1 color */
241   memset(colors, 0x44, colors_size);
242   num_colors = 1;
243   g_assert_cmpint (hb_ot_color_palette_get_colors (cpal_v0, 0, 0, &num_colors, colors), ==, 2);
244   g_assert_cmpint (num_colors, ==, 1);
245   assert_color_rgba (colors, 0, 0x00, 0x00, 0x00, 0xff);
246   assert_color_rgba (colors, 1, 0x44, 0x44, 0x44, 0x44);  /* untouched */
247
248   /* start_index > numPaletteEntries */
249   memset (colors, 0x44, colors_size);
250   num_colors = 2;
251   g_assert_cmpint (hb_ot_color_palette_get_colors (cpal_v0, 0, 9876, &num_colors, colors), ==, 2);
252   g_assert_cmpint (num_colors, ==, 0);
253   assert_color_rgba (colors, 0, 0x44, 0x44, 0x44, 0x44);  /* untouched */
254   assert_color_rgba (colors, 1, 0x44, 0x44, 0x44, 0x44);  /* untouched */
255 }
256
257
258 static void
259 test_hb_ot_color_palette_get_colors_v1 (void)
260 {
261   hb_color_t colors[3];
262   unsigned int num_colors = hb_ot_color_palette_get_colors (cpal_v1, 0, 0, NULL, NULL);
263   size_t colors_size = 3 * sizeof (hb_color_t);
264   g_assert_cmpint (num_colors, ==, 2);
265
266   /* Palette #0, start_index=0 */
267   memset (colors, 0x77, colors_size);
268   g_assert_cmpint (hb_ot_color_palette_get_colors (cpal_v1, 0, 0, &num_colors, colors), ==, 2);
269   g_assert_cmpint (num_colors, ==, 2);
270   assert_color_rgba (colors, 0, 0x00, 0x00, 0x00, 0xff);
271   assert_color_rgba (colors, 1, 0x66, 0xcc, 0xff, 0xff);
272   assert_color_rgba (colors, 2, 0x77, 0x77, 0x77, 0x77);  /* untouched */
273
274   /* Palette #1, start_index=0 */
275   memset (colors, 0x77, colors_size);
276   g_assert_cmpint (hb_ot_color_palette_get_colors (cpal_v1, 1, 0, &num_colors, colors), ==, 2);
277   g_assert_cmpint (num_colors, ==, 2);
278   assert_color_rgba (colors, 0, 0x00, 0x00, 0x00, 0xff);
279   assert_color_rgba (colors, 1, 0xff, 0xcc, 0x66, 0xff);
280   assert_color_rgba (colors, 2, 0x77, 0x77, 0x77, 0x77);  /* untouched */
281
282   /* Palette #2, start_index=0 */
283   memset (colors, 0x77, colors_size);
284   g_assert_cmpint (hb_ot_color_palette_get_colors (cpal_v1, 2, 0, &num_colors, colors), ==, 2);
285   g_assert_cmpint (num_colors, ==, 2);
286   assert_color_rgba (colors, 0, 0x00, 0x00, 0x00, 0xff);
287   assert_color_rgba (colors, 1, 0x80, 0x00, 0x00, 0xff);
288   assert_color_rgba (colors, 2, 0x77, 0x77, 0x77, 0x77);  /* untouched */
289
290   /* Palette #3 (out of bounds), start_index=0 */
291   memset (colors, 0x77, colors_size);
292   g_assert_cmpint (hb_ot_color_palette_get_colors (cpal_v1, 3, 0, &num_colors, colors), ==, 0);
293   g_assert_cmpint (num_colors, ==, 0);
294   assert_color_rgba (colors, 0, 0x77, 0x77, 0x77, 0x77);  /* untouched */
295   assert_color_rgba (colors, 1, 0x77, 0x77, 0x77, 0x77);  /* untouched */
296   assert_color_rgba (colors, 2, 0x77, 0x77, 0x77, 0x77);  /* untouched */
297 }
298
299
300 static void
301 test_hb_ot_color_palette_color_get_name_id (void)
302 {
303   g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (empty, 0), ==, HB_OT_NAME_ID_INVALID);
304   g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (empty, 1), ==, HB_OT_NAME_ID_INVALID);
305   g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (empty, 2), ==, HB_OT_NAME_ID_INVALID);
306   g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v0, 0), ==, HB_OT_NAME_ID_INVALID);
307   g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v0, 1), ==, HB_OT_NAME_ID_INVALID);
308   g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v0, 2), ==, HB_OT_NAME_ID_INVALID);
309   g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v1, 0), ==, HB_OT_NAME_ID_INVALID);
310   g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v1, 1), ==, 256);
311   g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v1, 2), ==, HB_OT_NAME_ID_INVALID);
312 }
313
314
315 static void
316 test_hb_ot_color_glyph_get_layers (void)
317 {
318   hb_ot_color_layer_t layers[1];
319   unsigned int count = 1;
320   unsigned int num_layers;
321
322   g_assert_cmpuint (hb_ot_color_glyph_get_layers (cpal_v1, 0, 0,
323                                                   NULL, NULL), ==, 0);
324   g_assert_cmpuint (hb_ot_color_glyph_get_layers (cpal_v1, 1, 0,
325                                                   NULL, NULL), ==, 0);
326   g_assert_cmpuint (hb_ot_color_glyph_get_layers (cpal_v1, 2, 0,
327                                                   NULL, NULL), ==, 2);
328
329   num_layers = hb_ot_color_glyph_get_layers (cpal_v1, 2, 0, &count, layers);
330
331   g_assert_cmpuint (num_layers, ==, 2);
332   g_assert_cmpuint (count, ==, 1);
333   g_assert_cmpuint (layers[0].glyph, ==, 3);
334   g_assert_cmpuint (layers[0].color_index, ==, 1);
335
336   count = 1;
337   hb_ot_color_glyph_get_layers (cpal_v1, 2, 1, &count, layers);
338
339   g_assert_cmpuint (num_layers, ==, 2);
340   g_assert_cmpuint (count, ==, 1);
341   g_assert_cmpuint (layers[0].glyph, ==, 4);
342   g_assert_cmpuint (layers[0].color_index, ==, 0);
343 }
344
345 static void
346 test_hb_ot_color_has_data (void)
347 {
348   g_assert (hb_ot_color_has_layers (empty) == FALSE);
349   g_assert (hb_ot_color_has_layers (cpal_v0) == TRUE);
350   g_assert (hb_ot_color_has_layers (cpal_v1) == TRUE);
351   g_assert (hb_ot_color_has_layers (cpal) == TRUE);
352   g_assert (hb_ot_color_has_layers (cbdt) == FALSE);
353   g_assert (hb_ot_color_has_layers (sbix) == FALSE);
354   g_assert (hb_ot_color_has_layers (svg) == FALSE);
355
356   g_assert (hb_ot_color_has_palettes (empty) == FALSE);
357   g_assert (hb_ot_color_has_palettes (cpal_v0) == TRUE);
358   g_assert (hb_ot_color_has_palettes (cpal_v1) == TRUE);
359   g_assert (hb_ot_color_has_palettes (cpal) == TRUE);
360   g_assert (hb_ot_color_has_palettes (cbdt) == FALSE);
361   g_assert (hb_ot_color_has_palettes (sbix) == FALSE);
362   g_assert (hb_ot_color_has_palettes (svg) == FALSE);
363
364   g_assert (hb_ot_color_has_svg (empty) == FALSE);
365   g_assert (hb_ot_color_has_svg (cpal_v0) == FALSE);
366   g_assert (hb_ot_color_has_svg (cpal_v1) == FALSE);
367   g_assert (hb_ot_color_has_svg (cpal) == FALSE);
368   g_assert (hb_ot_color_has_svg (cbdt) == FALSE);
369   g_assert (hb_ot_color_has_svg (sbix) == FALSE);
370   g_assert (hb_ot_color_has_svg (svg) == TRUE);
371
372   g_assert (hb_ot_color_has_png (empty) == FALSE);
373   g_assert (hb_ot_color_has_png (cpal_v0) == FALSE);
374   g_assert (hb_ot_color_has_png (cpal_v1) == FALSE);
375   g_assert (hb_ot_color_has_png (cpal) == FALSE);
376   g_assert (hb_ot_color_has_png (cbdt) == TRUE);
377   g_assert (hb_ot_color_has_png (sbix) == TRUE);
378   g_assert (hb_ot_color_has_png (svg) == FALSE);
379 }
380
381 static void
382 test_hb_ot_color_svg (void)
383 {
384   hb_blob_t *blob;
385   unsigned int length;
386   const char *data;
387
388   blob = hb_ot_color_glyph_reference_svg (svg, 0);
389   g_assert (hb_blob_get_length (blob) == 0);
390
391   blob = hb_ot_color_glyph_reference_svg (svg, 1);
392   data = hb_blob_get_data (blob, &length);
393   g_assert_cmpuint (length, ==, 146);
394   g_assert (strncmp (data, "<?xml", 4) == 0);
395   g_assert (strncmp (data + 140, "</svg>", 5) == 0);
396   hb_blob_destroy (blob);
397
398   blob = hb_ot_color_glyph_reference_svg (empty, 0);
399   g_assert (hb_blob_get_length (blob) == 0);
400 }
401
402
403 static void
404 test_hb_ot_color_png (void)
405 {
406   hb_blob_t *blob;
407   unsigned int length;
408   const char *data;
409   hb_glyph_extents_t extents;
410   hb_font_t *cbdt_font;
411
412   /* sbix */
413   hb_font_t *sbix_font;
414   sbix_font = hb_font_create (sbix);
415   blob = hb_ot_color_glyph_reference_png (sbix_font, 0);
416   hb_font_get_glyph_extents (sbix_font, 0, &extents);
417   g_assert_cmpint (extents.x_bearing, ==, 0);
418   g_assert_cmpint (extents.y_bearing, ==, 0);
419   g_assert_cmpint (extents.width, ==, 0);
420   g_assert_cmpint (extents.height, ==, 0);
421   g_assert (hb_blob_get_length (blob) == 0);
422
423   blob = hb_ot_color_glyph_reference_png (sbix_font, 1);
424   data = hb_blob_get_data (blob, &length);
425   g_assert_cmpuint (length, ==, 224);
426   g_assert (strncmp (data + 1, "PNG", 3) == 0);
427   hb_font_get_glyph_extents (sbix_font, 1, &extents);
428   g_assert_cmpint (extents.x_bearing, ==, 0);
429   g_assert_cmpint (extents.y_bearing, ==, 0);
430   g_assert_cmpint (extents.width, ==, 800);
431   g_assert_cmpint (extents.height, ==, 800);
432   hb_blob_destroy (blob);
433   hb_font_destroy (sbix_font);
434
435   /* cbdt */
436   cbdt_font = hb_font_create (cbdt);
437   blob = hb_ot_color_glyph_reference_png (cbdt_font, 0);
438   g_assert (hb_blob_get_length (blob) == 0);
439
440   blob = hb_ot_color_glyph_reference_png (cbdt_font, 1);
441   data = hb_blob_get_data (blob, &length);
442   g_assert_cmpuint (length, ==, 88);
443   g_assert (strncmp (data + 1, "PNG", 3) == 0);
444   hb_font_get_glyph_extents (cbdt_font, 1, &extents);
445   g_assert_cmpint (extents.x_bearing, ==, 0);
446   g_assert_cmpint (extents.y_bearing, ==, 1024);
447   g_assert_cmpint (extents.width, ==, 1024);
448   g_assert_cmpint (extents.height, ==, -1024);
449   hb_blob_destroy (blob);
450   hb_font_destroy (cbdt_font);
451 }
452
453 int
454 main (int argc, char **argv)
455 {
456   int status = 0;
457
458   hb_test_init (&argc, &argv);
459   cpal_v0 = hb_test_open_font_file ("fonts/cpal-v0.ttf");
460   cpal_v1 = hb_test_open_font_file ("fonts/cpal-v1.ttf");
461   cpal = hb_test_open_font_file ("fonts/chromacheck-colr.ttf");
462   cbdt = hb_test_open_font_file ("fonts/chromacheck-cbdt.ttf");
463   sbix = hb_test_open_font_file ("fonts/chromacheck-sbix.ttf");
464   svg = hb_test_open_font_file ("fonts/chromacheck-svg.ttf");
465   empty = hb_face_get_empty ();
466   hb_test_add (test_hb_ot_color_palette_get_count);
467   hb_test_add (test_hb_ot_color_palette_get_name_id_empty);
468   hb_test_add (test_hb_ot_color_palette_get_name_id_v0);
469   hb_test_add (test_hb_ot_color_palette_get_name_id_v1);
470   hb_test_add (test_hb_ot_color_palette_get_flags_empty);
471   hb_test_add (test_hb_ot_color_palette_get_flags_v0);
472   hb_test_add (test_hb_ot_color_palette_get_flags_v1);
473   hb_test_add (test_hb_ot_color_palette_get_colors_empty);
474   hb_test_add (test_hb_ot_color_palette_get_colors_v0);
475   hb_test_add (test_hb_ot_color_palette_get_colors_v1);
476   hb_test_add (test_hb_ot_color_palette_color_get_name_id);
477   hb_test_add (test_hb_ot_color_glyph_get_layers);
478   hb_test_add (test_hb_ot_color_has_data);
479   hb_test_add (test_hb_ot_color_png);
480   hb_test_add (test_hb_ot_color_svg);
481   status = hb_test_run();
482   hb_face_destroy (cpal_v0);
483   hb_face_destroy (cpal_v1);
484   hb_face_destroy (cpal);
485   hb_face_destroy (cbdt);
486   hb_face_destroy (sbix);
487   hb_face_destroy (svg);
488   return status;
489 }