c2bbad2d560cd6cc5f1cad290c07b74d4ce28331
[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*) malloc (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   free (colors);
257 }
258
259
260 static void
261 test_hb_ot_color_palette_get_colors_v1 (void)
262 {
263   hb_color_t colors[3];
264   unsigned int num_colors = hb_ot_color_palette_get_colors (cpal_v1, 0, 0, NULL, NULL);
265   size_t colors_size = 3 * sizeof (hb_color_t);
266   g_assert_cmpint (num_colors, ==, 2);
267
268   /* Palette #0, start_index=0 */
269   memset (colors, 0x77, colors_size);
270   g_assert_cmpint (hb_ot_color_palette_get_colors (cpal_v1, 0, 0, &num_colors, colors), ==, 2);
271   g_assert_cmpint (num_colors, ==, 2);
272   assert_color_rgba (colors, 0, 0x00, 0x00, 0x00, 0xff);
273   assert_color_rgba (colors, 1, 0x66, 0xcc, 0xff, 0xff);
274   assert_color_rgba (colors, 2, 0x77, 0x77, 0x77, 0x77);  /* untouched */
275
276   /* Palette #1, start_index=0 */
277   memset (colors, 0x77, colors_size);
278   g_assert_cmpint (hb_ot_color_palette_get_colors (cpal_v1, 1, 0, &num_colors, colors), ==, 2);
279   g_assert_cmpint (num_colors, ==, 2);
280   assert_color_rgba (colors, 0, 0x00, 0x00, 0x00, 0xff);
281   assert_color_rgba (colors, 1, 0xff, 0xcc, 0x66, 0xff);
282   assert_color_rgba (colors, 2, 0x77, 0x77, 0x77, 0x77);  /* untouched */
283
284   /* Palette #2, start_index=0 */
285   memset (colors, 0x77, colors_size);
286   g_assert_cmpint (hb_ot_color_palette_get_colors (cpal_v1, 2, 0, &num_colors, colors), ==, 2);
287   g_assert_cmpint (num_colors, ==, 2);
288   assert_color_rgba (colors, 0, 0x00, 0x00, 0x00, 0xff);
289   assert_color_rgba (colors, 1, 0x80, 0x00, 0x00, 0xff);
290   assert_color_rgba (colors, 2, 0x77, 0x77, 0x77, 0x77);  /* untouched */
291
292   /* Palette #3 (out of bounds), start_index=0 */
293   memset (colors, 0x77, colors_size);
294   g_assert_cmpint (hb_ot_color_palette_get_colors (cpal_v1, 3, 0, &num_colors, colors), ==, 0);
295   g_assert_cmpint (num_colors, ==, 0);
296   assert_color_rgba (colors, 0, 0x77, 0x77, 0x77, 0x77);  /* untouched */
297   assert_color_rgba (colors, 1, 0x77, 0x77, 0x77, 0x77);  /* untouched */
298   assert_color_rgba (colors, 2, 0x77, 0x77, 0x77, 0x77);  /* untouched */
299 }
300
301
302 static void
303 test_hb_ot_color_palette_color_get_name_id (void)
304 {
305   g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (empty, 0), ==, HB_OT_NAME_ID_INVALID);
306   g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (empty, 1), ==, HB_OT_NAME_ID_INVALID);
307   g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (empty, 2), ==, HB_OT_NAME_ID_INVALID);
308   g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v0, 0), ==, HB_OT_NAME_ID_INVALID);
309   g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v0, 1), ==, HB_OT_NAME_ID_INVALID);
310   g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v0, 2), ==, HB_OT_NAME_ID_INVALID);
311   g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v1, 0), ==, HB_OT_NAME_ID_INVALID);
312   g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v1, 1), ==, 256);
313   g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v1, 2), ==, HB_OT_NAME_ID_INVALID);
314 }
315
316
317 static void
318 test_hb_ot_color_glyph_get_layers (void)
319 {
320   hb_ot_color_layer_t layers[1];
321   unsigned int count = 1;
322   unsigned int num_layers;
323
324   g_assert_cmpuint (hb_ot_color_glyph_get_layers (cpal_v1, 0, 0,
325                                                   NULL, NULL), ==, 0);
326   g_assert_cmpuint (hb_ot_color_glyph_get_layers (cpal_v1, 1, 0,
327                                                   NULL, NULL), ==, 0);
328   g_assert_cmpuint (hb_ot_color_glyph_get_layers (cpal_v1, 2, 0,
329                                                   NULL, NULL), ==, 2);
330
331   num_layers = hb_ot_color_glyph_get_layers (cpal_v1, 2, 0, &count, layers);
332
333   g_assert_cmpuint (num_layers, ==, 2);
334   g_assert_cmpuint (count, ==, 1);
335   g_assert_cmpuint (layers[0].glyph, ==, 3);
336   g_assert_cmpuint (layers[0].color_index, ==, 1);
337
338   count = 1;
339   hb_ot_color_glyph_get_layers (cpal_v1, 2, 1, &count, layers);
340
341   g_assert_cmpuint (num_layers, ==, 2);
342   g_assert_cmpuint (count, ==, 1);
343   g_assert_cmpuint (layers[0].glyph, ==, 4);
344   g_assert_cmpuint (layers[0].color_index, ==, 0);
345 }
346
347 static void
348 test_hb_ot_color_has_data (void)
349 {
350   g_assert (hb_ot_color_has_layers (empty) == FALSE);
351   g_assert (hb_ot_color_has_layers (cpal_v0) == TRUE);
352   g_assert (hb_ot_color_has_layers (cpal_v1) == TRUE);
353   g_assert (hb_ot_color_has_layers (cpal) == TRUE);
354   g_assert (hb_ot_color_has_layers (cbdt) == FALSE);
355   g_assert (hb_ot_color_has_layers (sbix) == FALSE);
356   g_assert (hb_ot_color_has_layers (svg) == FALSE);
357
358   g_assert (hb_ot_color_has_palettes (empty) == FALSE);
359   g_assert (hb_ot_color_has_palettes (cpal_v0) == TRUE);
360   g_assert (hb_ot_color_has_palettes (cpal_v1) == TRUE);
361   g_assert (hb_ot_color_has_palettes (cpal) == TRUE);
362   g_assert (hb_ot_color_has_palettes (cbdt) == FALSE);
363   g_assert (hb_ot_color_has_palettes (sbix) == FALSE);
364   g_assert (hb_ot_color_has_palettes (svg) == FALSE);
365
366   g_assert (hb_ot_color_has_svg (empty) == FALSE);
367   g_assert (hb_ot_color_has_svg (cpal_v0) == FALSE);
368   g_assert (hb_ot_color_has_svg (cpal_v1) == FALSE);
369   g_assert (hb_ot_color_has_svg (cpal) == FALSE);
370   g_assert (hb_ot_color_has_svg (cbdt) == FALSE);
371   g_assert (hb_ot_color_has_svg (sbix) == FALSE);
372   g_assert (hb_ot_color_has_svg (svg) == TRUE);
373
374   g_assert (hb_ot_color_has_png (empty) == FALSE);
375   g_assert (hb_ot_color_has_png (cpal_v0) == FALSE);
376   g_assert (hb_ot_color_has_png (cpal_v1) == FALSE);
377   g_assert (hb_ot_color_has_png (cpal) == FALSE);
378   g_assert (hb_ot_color_has_png (cbdt) == TRUE);
379   g_assert (hb_ot_color_has_png (sbix) == TRUE);
380   g_assert (hb_ot_color_has_png (svg) == FALSE);
381 }
382
383 static void
384 test_hb_ot_color_svg (void)
385 {
386   hb_blob_t *blob;
387   unsigned int length;
388   const char *data;
389
390   blob = hb_ot_color_glyph_reference_svg (svg, 0);
391   g_assert (hb_blob_get_length (blob) == 0);
392
393   blob = hb_ot_color_glyph_reference_svg (svg, 1);
394   data = hb_blob_get_data (blob, &length);
395   g_assert_cmpuint (length, ==, 146);
396   g_assert (strncmp (data, "<?xml", 4) == 0);
397   g_assert (strncmp (data + 140, "</svg>", 5) == 0);
398   hb_blob_destroy (blob);
399
400   blob = hb_ot_color_glyph_reference_svg (empty, 0);
401   g_assert (hb_blob_get_length (blob) == 0);
402 }
403
404
405 static void
406 test_hb_ot_color_png (void)
407 {
408   hb_blob_t *blob;
409   unsigned int length;
410   const char *data;
411   hb_glyph_extents_t extents;
412   hb_font_t *cbdt_font;
413
414   /* sbix */
415   hb_font_t *sbix_font;
416   sbix_font = hb_font_create (sbix);
417   blob = hb_ot_color_glyph_reference_png (sbix_font, 0);
418   hb_font_get_glyph_extents (sbix_font, 0, &extents);
419   g_assert_cmpint (extents.x_bearing, ==, 0);
420   g_assert_cmpint (extents.y_bearing, ==, 0);
421   g_assert_cmpint (extents.width, ==, 0);
422   g_assert_cmpint (extents.height, ==, 0);
423   g_assert (hb_blob_get_length (blob) == 0);
424
425   blob = hb_ot_color_glyph_reference_png (sbix_font, 1);
426   data = hb_blob_get_data (blob, &length);
427   g_assert_cmpuint (length, ==, 224);
428   g_assert (strncmp (data + 1, "PNG", 3) == 0);
429   hb_font_get_glyph_extents (sbix_font, 1, &extents);
430   g_assert_cmpint (extents.x_bearing, ==, 0);
431   g_assert_cmpint (extents.y_bearing, ==, 800);
432   g_assert_cmpint (extents.width, ==, 800);
433   g_assert_cmpint (extents.height, ==, -800);
434   hb_blob_destroy (blob);
435   hb_font_destroy (sbix_font);
436
437   /* cbdt */
438   cbdt_font = hb_font_create (cbdt);
439   blob = hb_ot_color_glyph_reference_png (cbdt_font, 0);
440   g_assert (hb_blob_get_length (blob) == 0);
441
442   blob = hb_ot_color_glyph_reference_png (cbdt_font, 1);
443   data = hb_blob_get_data (blob, &length);
444   g_assert_cmpuint (length, ==, 88);
445   g_assert (strncmp (data + 1, "PNG", 3) == 0);
446   hb_font_get_glyph_extents (cbdt_font, 1, &extents);
447   g_assert_cmpint (extents.x_bearing, ==, 0);
448   g_assert_cmpint (extents.y_bearing, ==, 1024);
449   g_assert_cmpint (extents.width, ==, 1024);
450   g_assert_cmpint (extents.height, ==, -1024);
451   hb_blob_destroy (blob);
452   hb_font_destroy (cbdt_font);
453 }
454
455 int
456 main (int argc, char **argv)
457 {
458   int status = 0;
459
460   hb_test_init (&argc, &argv);
461   cpal_v0 = hb_test_open_font_file ("fonts/cpal-v0.ttf");
462   cpal_v1 = hb_test_open_font_file ("fonts/cpal-v1.ttf");
463   cpal = hb_test_open_font_file ("fonts/chromacheck-colr.ttf");
464   cbdt = hb_test_open_font_file ("fonts/chromacheck-cbdt.ttf");
465   sbix = hb_test_open_font_file ("fonts/chromacheck-sbix.ttf");
466   svg = hb_test_open_font_file ("fonts/chromacheck-svg.ttf");
467   empty = hb_face_get_empty ();
468   hb_test_add (test_hb_ot_color_palette_get_count);
469   hb_test_add (test_hb_ot_color_palette_get_name_id_empty);
470   hb_test_add (test_hb_ot_color_palette_get_name_id_v0);
471   hb_test_add (test_hb_ot_color_palette_get_name_id_v1);
472   hb_test_add (test_hb_ot_color_palette_get_flags_empty);
473   hb_test_add (test_hb_ot_color_palette_get_flags_v0);
474   hb_test_add (test_hb_ot_color_palette_get_flags_v1);
475   hb_test_add (test_hb_ot_color_palette_get_colors_empty);
476   hb_test_add (test_hb_ot_color_palette_get_colors_v0);
477   hb_test_add (test_hb_ot_color_palette_get_colors_v1);
478   hb_test_add (test_hb_ot_color_palette_color_get_name_id);
479   hb_test_add (test_hb_ot_color_glyph_get_layers);
480   hb_test_add (test_hb_ot_color_has_data);
481   hb_test_add (test_hb_ot_color_png);
482   hb_test_add (test_hb_ot_color_svg);
483   status = hb_test_run();
484   hb_face_destroy (cpal_v0);
485   hb_face_destroy (cpal_v1);
486   hb_face_destroy (cpal);
487   hb_face_destroy (cbdt);
488   hb_face_destroy (sbix);
489   hb_face_destroy (svg);
490   return status;
491 }