1 /*
2 * Copyright © 2011 Google, Inc.
3 *
4 * This is part of HarfBuzz, a text shaping library.
5 *
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.
11 *
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
16 * DAMAGE.
17 *
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.
23 *
24 * Google Author(s): Behdad Esfahbod
25 */
26
27 #include "hb-test.h"
28
29 /* Unit tests for hb-font.h */
30
31
32 static const char test_data[] = "test\0data";
33
34
35 static void
test_face_empty(void)36 test_face_empty (void)
37 {
38 hb_face_t *created_from_empty;
39 hb_face_t *created_from_null;
40
41 g_assert (hb_face_get_empty ());
42
43 created_from_empty = hb_face_create (hb_blob_get_empty (), 0);
44 g_assert (hb_face_get_empty () != created_from_empty);
45
46 created_from_null = hb_face_create (NULL, 0);
47 g_assert (hb_face_get_empty () != created_from_null);
48
49 g_assert (hb_face_reference_table (hb_face_get_empty (), HB_TAG ('h','e','a','d')) == hb_blob_get_empty ());
50
51 g_assert_cmpint (hb_face_get_upem (hb_face_get_empty ()), ==, 1000);
52
53 hb_face_destroy (created_from_null);
54 hb_face_destroy (created_from_empty);
55 }
56
57 static void
test_face_create(void)58 test_face_create (void)
59 {
60 hb_face_t *face;
61 hb_blob_t *blob;
62
63 blob = hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL);
64 face = hb_face_create (blob, 0);
65 hb_blob_destroy (blob);
66
67 g_assert (hb_face_reference_table (face, HB_TAG ('h','e','a','d')) == hb_blob_get_empty ());
68
69 g_assert_cmpint (hb_face_get_upem (face), ==, 1000);
70
71 hb_face_destroy (face);
72 }
73
74
75 static void
free_up(void * user_data)76 free_up (void *user_data)
77 {
78 int *freed = (int *) user_data;
79
80 g_assert (!*freed);
81
82 (*freed)++;
83 }
84
85 static hb_blob_t *
get_table(hb_face_t * face HB_UNUSED,hb_tag_t tag,void * user_data HB_UNUSED)86 get_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data HB_UNUSED)
87 {
88 if (tag == HB_TAG ('a','b','c','d'))
89 return hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL);
90
91 return hb_blob_get_empty ();
92 }
93
94 static void
test_face_createfortables(void)95 test_face_createfortables (void)
96 {
97 hb_face_t *face;
98 hb_blob_t *blob;
99 const char *data;
100 unsigned int len;
101 int freed = 0;
102
103 face = hb_face_create_for_tables (get_table, &freed, free_up);
104 g_assert (!freed);
105
106 g_assert (hb_face_reference_table (face, HB_TAG ('h','e','a','d')) == hb_blob_get_empty ());
107
108 blob = hb_face_reference_table (face, HB_TAG ('a','b','c','d'));
109 g_assert (blob != hb_blob_get_empty ());
110
111 data = hb_blob_get_data (blob, &len);
112 g_assert_cmpint (len, ==, sizeof (test_data));
113 g_assert (0 == memcmp (data, test_data, sizeof (test_data)));
114 hb_blob_destroy (blob);
115
116 g_assert_cmpint (hb_face_get_upem (face), ==, 1000);
117
118 hb_face_destroy (face);
119 g_assert (freed);
120 }
121
122 static void
_test_font_nil_funcs(hb_font_t * font)123 _test_font_nil_funcs (hb_font_t *font)
124 {
125 hb_codepoint_t glyph;
126 hb_position_t x, y;
127 hb_glyph_extents_t extents;
128 unsigned int upem = hb_face_get_upem (hb_font_get_face (font));
129
130 x = y = 13;
131 g_assert (!hb_font_get_glyph_contour_point (font, 17, 2, &x, &y));
132 g_assert_cmpint (x, ==, 0);
133 g_assert_cmpint (y, ==, 0);
134
135 x = hb_font_get_glyph_h_advance (font, 17);
136 g_assert_cmpint (x, ==, upem);
137
138 extents.x_bearing = extents.y_bearing = 13;
139 extents.width = extents.height = 15;
140 hb_font_get_glyph_extents (font, 17, &extents);
141 g_assert_cmpint (extents.x_bearing, ==, 0);
142 g_assert_cmpint (extents.y_bearing, ==, 0);
143 g_assert_cmpint (extents.width, ==, 0);
144 g_assert_cmpint (extents.height, ==, 0);
145
146 glyph = 3;
147 g_assert (!hb_font_get_glyph (font, 17, 2, &glyph));
148 g_assert_cmpint (glyph, ==, 0);
149
150 x = hb_font_get_glyph_h_kerning (font, 17, 19);
151 g_assert_cmpint (x, ==, 0);
152 }
153
154 static void
_test_fontfuncs_nil(hb_font_funcs_t * ffuncs)155 _test_fontfuncs_nil (hb_font_funcs_t *ffuncs)
156 {
157 hb_blob_t *blob;
158 hb_face_t *face;
159 hb_font_t *font;
160 hb_font_t *subfont;
161 int freed = 0;
162
163 blob = hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL);
164 face = hb_face_create (blob, 0);
165 hb_blob_destroy (blob);
166 g_assert (!hb_face_is_immutable (face));
167 font = hb_font_create (face);
168 g_assert (font);
169 g_assert (hb_face_is_immutable (face));
170 hb_face_destroy (face);
171
172
173 hb_font_set_funcs (font, ffuncs, &freed, free_up);
174 g_assert_cmpint (freed, ==, 0);
175
176 _test_font_nil_funcs (font);
177
178 subfont = hb_font_create_sub_font (font);
179 g_assert (subfont);
180
181 g_assert_cmpint (freed, ==, 0);
182 hb_font_destroy (font);
183 g_assert_cmpint (freed, ==, 0);
184
185 _test_font_nil_funcs (subfont);
186
187 hb_font_destroy (subfont);
188 g_assert_cmpint (freed, ==, 1);
189 }
190
191 static void
test_fontfuncs_empty(void)192 test_fontfuncs_empty (void)
193 {
194 g_assert (hb_font_funcs_get_empty ());
195 g_assert (hb_font_funcs_is_immutable (hb_font_funcs_get_empty ()));
196 _test_fontfuncs_nil (hb_font_funcs_get_empty ());
197 }
198
199 static void
test_fontfuncs_nil(void)200 test_fontfuncs_nil (void)
201 {
202 hb_font_funcs_t *ffuncs;
203
204 ffuncs = hb_font_funcs_create ();
205
206 g_assert (!hb_font_funcs_is_immutable (ffuncs));
207 _test_fontfuncs_nil (hb_font_funcs_get_empty ());
208
209 hb_font_funcs_destroy (ffuncs);
210 }
211
212 static hb_bool_t
contour_point_func1(hb_font_t * font HB_UNUSED,void * font_data HB_UNUSED,hb_codepoint_t glyph,unsigned int point_index HB_UNUSED,hb_position_t * x,hb_position_t * y,void * user_data HB_UNUSED)213 contour_point_func1 (hb_font_t *font HB_UNUSED, void *font_data HB_UNUSED,
214 hb_codepoint_t glyph, unsigned int point_index HB_UNUSED,
215 hb_position_t *x, hb_position_t *y,
216 void *user_data HB_UNUSED)
217 {
218 if (glyph == 1) {
219 *x = 2;
220 *y = 3;
221 return TRUE;
222 }
223 if (glyph == 2) {
224 *x = 4;
225 *y = 5;
226 return TRUE;
227 }
228
229 return FALSE;
230 }
231
232 static hb_bool_t
contour_point_func2(hb_font_t * font,void * font_data HB_UNUSED,hb_codepoint_t glyph,unsigned int point_index,hb_position_t * x,hb_position_t * y,void * user_data HB_UNUSED)233 contour_point_func2 (hb_font_t *font, void *font_data HB_UNUSED,
234 hb_codepoint_t glyph, unsigned int point_index,
235 hb_position_t *x, hb_position_t *y,
236 void *user_data HB_UNUSED)
237 {
238 if (glyph == 1) {
239 *x = 6;
240 *y = 7;
241 return TRUE;
242 }
243
244 return hb_font_get_glyph_contour_point (hb_font_get_parent (font),
245 glyph, point_index, x, y);
246 }
247
248 static hb_position_t
glyph_h_advance_func1(hb_font_t * font HB_UNUSED,void * font_data HB_UNUSED,hb_codepoint_t glyph,void * user_data HB_UNUSED)249 glyph_h_advance_func1 (hb_font_t *font HB_UNUSED, void *font_data HB_UNUSED,
250 hb_codepoint_t glyph,
251 void *user_data HB_UNUSED)
252 {
253 if (glyph == 1)
254 return 8;
255
256 return 0;
257 }
258
259 static void
test_fontfuncs_subclassing(void)260 test_fontfuncs_subclassing (void)
261 {
262 hb_blob_t *blob;
263 hb_face_t *face;
264
265 hb_font_funcs_t *ffuncs1;
266 hb_font_funcs_t *ffuncs2;
267
268 hb_font_t *font1;
269 hb_font_t *font2;
270 hb_font_t *font3;
271
272 hb_position_t x;
273 hb_position_t y;
274
275 blob = hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL);
276 face = hb_face_create (blob, 0);
277 hb_blob_destroy (blob);
278 font1 = hb_font_create (face);
279 hb_face_destroy (face);
280 hb_font_set_scale (font1, 10, 10);
281
282 /* setup font1 */
283 ffuncs1 = hb_font_funcs_create ();
284 hb_font_funcs_set_glyph_contour_point_func (ffuncs1, contour_point_func1, NULL, NULL);
285 hb_font_funcs_set_glyph_h_advance_func (ffuncs1, glyph_h_advance_func1, NULL, NULL);
286 hb_font_set_funcs (font1, ffuncs1, NULL, NULL);
287 hb_font_funcs_destroy (ffuncs1);
288
289 x = y = 1;
290 g_assert (hb_font_get_glyph_contour_point_for_origin (font1, 1, 2, HB_DIRECTION_LTR, &x, &y));
291 g_assert_cmpint (x, ==, 2);
292 g_assert_cmpint (y, ==, 3);
293 g_assert (hb_font_get_glyph_contour_point_for_origin (font1, 2, 5, HB_DIRECTION_LTR, &x, &y));
294 g_assert_cmpint (x, ==, 4);
295 g_assert_cmpint (y, ==, 5);
296 g_assert (!hb_font_get_glyph_contour_point_for_origin (font1, 3, 7, HB_DIRECTION_RTL, &x, &y));
297 g_assert_cmpint (x, ==, 0);
298 g_assert_cmpint (y, ==, 0);
299 x = hb_font_get_glyph_h_advance (font1, 1);
300 g_assert_cmpint (x, ==, 8);
301 x = hb_font_get_glyph_h_advance (font1, 2);
302 g_assert_cmpint (x, ==, 0);
303
304 /* creating sub-font doesn't make the parent font immutable;
305 * making a font immutable however makes it's lineage immutable.
306 */
307 font2 = hb_font_create_sub_font (font1);
308 font3 = hb_font_create_sub_font (font2);
309 g_assert (!hb_font_is_immutable (font1));
310 g_assert (!hb_font_is_immutable (font2));
311 g_assert (!hb_font_is_immutable (font3));
312 hb_font_make_immutable (font3);
313 g_assert (hb_font_is_immutable (font1));
314 g_assert (hb_font_is_immutable (font2));
315 g_assert (hb_font_is_immutable (font3));
316 hb_font_destroy (font2);
317 hb_font_destroy (font3);
318
319 font2 = hb_font_create_sub_font (font1);
320 hb_font_destroy (font1);
321
322 /* setup font2 to override some funcs */
323 ffuncs2 = hb_font_funcs_create ();
324 hb_font_funcs_set_glyph_contour_point_func (ffuncs2, contour_point_func2, NULL, NULL);
325 hb_font_set_funcs (font2, ffuncs2, NULL, NULL);
326 hb_font_funcs_destroy (ffuncs2);
327
328 x = y = 1;
329 g_assert (hb_font_get_glyph_contour_point_for_origin (font2, 1, 2, HB_DIRECTION_LTR, &x, &y));
330 g_assert_cmpint (x, ==, 6);
331 g_assert_cmpint (y, ==, 7);
332 g_assert (hb_font_get_glyph_contour_point_for_origin (font2, 2, 5, HB_DIRECTION_RTL, &x, &y));
333 g_assert_cmpint (x, ==, 4);
334 g_assert_cmpint (y, ==, 5);
335 g_assert (!hb_font_get_glyph_contour_point_for_origin (font2, 3, 7, HB_DIRECTION_LTR, &x, &y));
336 g_assert_cmpint (x, ==, 0);
337 g_assert_cmpint (y, ==, 0);
338 x = hb_font_get_glyph_h_advance (font2, 1);
339 g_assert_cmpint (x, ==, 8);
340 x = hb_font_get_glyph_h_advance (font2, 2);
341 g_assert_cmpint (x, ==, 0);
342
343 /* setup font3 to override scale */
344 font3 = hb_font_create_sub_font (font2);
345 hb_font_set_scale (font3, 20, 30);
346
347 x = y = 1;
348 g_assert (hb_font_get_glyph_contour_point_for_origin (font3, 1, 2, HB_DIRECTION_RTL, &x, &y));
349 g_assert_cmpint (x, ==, 6*2);
350 g_assert_cmpint (y, ==, 7*3);
351 g_assert (hb_font_get_glyph_contour_point_for_origin (font3, 2, 5, HB_DIRECTION_LTR, &x, &y));
352 g_assert_cmpint (x, ==, 4*2);
353 g_assert_cmpint (y, ==, 5*3);
354 g_assert (!hb_font_get_glyph_contour_point_for_origin (font3, 3, 7, HB_DIRECTION_LTR, &x, &y));
355 g_assert_cmpint (x, ==, 0*2);
356 g_assert_cmpint (y, ==, 0*3);
357 x = hb_font_get_glyph_h_advance (font3, 1);
358 g_assert_cmpint (x, ==, 8*2);
359 x = hb_font_get_glyph_h_advance (font3, 2);
360 g_assert_cmpint (x, ==, 0*2);
361
362
363 hb_font_destroy (font3);
364 hb_font_destroy (font2);
365 }
366
367 static hb_bool_t
nominal_glyph_func(hb_font_t * font HB_UNUSED,void * font_data HB_UNUSED,hb_codepoint_t unicode HB_UNUSED,hb_codepoint_t * glyph,void * user_data HB_UNUSED)368 nominal_glyph_func (hb_font_t *font HB_UNUSED,
369 void *font_data HB_UNUSED,
370 hb_codepoint_t unicode HB_UNUSED,
371 hb_codepoint_t *glyph,
372 void *user_data HB_UNUSED)
373 {
374 *glyph = 0;
375 return FALSE;
376 }
377
378 static unsigned int
nominal_glyphs_func(hb_font_t * font HB_UNUSED,void * font_data HB_UNUSED,unsigned int count HB_UNUSED,const hb_codepoint_t * first_unicode HB_UNUSED,unsigned int unicode_stride HB_UNUSED,hb_codepoint_t * first_glyph HB_UNUSED,unsigned int glyph_stride HB_UNUSED,void * user_data HB_UNUSED)379 nominal_glyphs_func (hb_font_t *font HB_UNUSED,
380 void *font_data HB_UNUSED,
381 unsigned int count HB_UNUSED,
382 const hb_codepoint_t *first_unicode HB_UNUSED,
383 unsigned int unicode_stride HB_UNUSED,
384 hb_codepoint_t *first_glyph HB_UNUSED,
385 unsigned int glyph_stride HB_UNUSED,
386 void *user_data HB_UNUSED)
387 {
388 return 0;
389 }
390
391 static void
test_fontfuncs_parallels(void)392 test_fontfuncs_parallels (void)
393 {
394 hb_blob_t *blob;
395 hb_face_t *face;
396
397 hb_font_funcs_t *ffuncs1;
398 hb_font_funcs_t *ffuncs2;
399
400 hb_font_t *font0;
401 hb_font_t *font1;
402 hb_font_t *font2;
403 hb_codepoint_t glyph;
404
405 blob = hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL);
406 face = hb_face_create (blob, 0);
407 hb_blob_destroy (blob);
408 font0 = hb_font_create (face);
409 hb_face_destroy (face);
410
411 /* setup sub-font1 */
412 font1 = hb_font_create_sub_font (font0);
413 hb_font_destroy (font0);
414 ffuncs1 = hb_font_funcs_create ();
415 hb_font_funcs_set_nominal_glyph_func (ffuncs1, nominal_glyph_func, NULL, NULL);
416 hb_font_set_funcs (font1, ffuncs1, NULL, NULL);
417 hb_font_funcs_destroy (ffuncs1);
418
419 /* setup sub-font2 */
420 font2 = hb_font_create_sub_font (font1);
421 hb_font_destroy (font1);
422 ffuncs2 = hb_font_funcs_create ();
423 hb_font_funcs_set_nominal_glyphs_func (ffuncs1, nominal_glyphs_func, NULL, NULL);
424 hb_font_set_funcs (font2, ffuncs2, NULL, NULL);
425 hb_font_funcs_destroy (ffuncs2);
426
427 /* Just test that calling get_nominal_glyph doesn't infinite-loop. */
428 hb_font_get_nominal_glyph (font2, 0x0020u, &glyph);
429
430 hb_font_destroy (font2);
431 }
432
433 static void
test_font_empty(void)434 test_font_empty (void)
435 {
436 hb_font_t *created_from_empty;
437 hb_font_t *created_from_null;
438 hb_font_t *created_sub_from_null;
439
440 g_assert (hb_font_get_empty ());
441
442 created_from_empty = hb_font_create (hb_face_get_empty ());
443 g_assert (hb_font_get_empty () != created_from_empty);
444
445 created_from_null = hb_font_create (NULL);
446 g_assert (hb_font_get_empty () != created_from_null);
447
448 created_sub_from_null = hb_font_create_sub_font (NULL);
449 g_assert (hb_font_get_empty () != created_sub_from_null);
450
451 g_assert (hb_font_is_immutable (hb_font_get_empty ()));
452
453 g_assert (hb_font_get_face (hb_font_get_empty ()) == hb_face_get_empty ());
454 g_assert (hb_font_get_parent (hb_font_get_empty ()) == NULL);
455
456 hb_font_destroy (created_sub_from_null);
457 hb_font_destroy (created_from_null);
458 hb_font_destroy (created_from_empty);
459 }
460
461 static void
test_font_properties(void)462 test_font_properties (void)
463 {
464 hb_blob_t *blob;
465 hb_face_t *face;
466 hb_font_t *font;
467 hb_font_t *subfont;
468 int x_scale, y_scale;
469 unsigned int x_ppem, y_ppem;
470 unsigned int upem;
471
472 blob = hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL);
473 face = hb_face_create (blob, 0);
474 hb_blob_destroy (blob);
475 font = hb_font_create (face);
476 hb_face_destroy (face);
477
478
479 g_assert (hb_font_get_face (font) == face);
480 g_assert (hb_font_get_parent (font) == hb_font_get_empty ());
481 subfont = hb_font_create_sub_font (font);
482 g_assert (hb_font_get_parent (subfont) == font);
483 hb_font_set_parent(subfont, NULL);
484 g_assert (hb_font_get_parent (subfont) == hb_font_get_empty());
485 hb_font_set_parent(subfont, font);
486 g_assert (hb_font_get_parent (subfont) == font);
487 hb_font_set_parent(subfont, NULL);
488 hb_font_make_immutable (subfont);
489 g_assert (hb_font_get_parent (subfont) == hb_font_get_empty());
490 hb_font_set_parent(subfont, font);
491 g_assert (hb_font_get_parent (subfont) == hb_font_get_empty());
492 hb_font_destroy (subfont);
493
494
495 /* Check scale */
496
497 upem = hb_face_get_upem (hb_font_get_face (font));
498 hb_font_get_scale (font, NULL, NULL);
499 x_scale = y_scale = 13;
500 hb_font_get_scale (font, &x_scale, NULL);
501 g_assert_cmpint (x_scale, ==, upem);
502 x_scale = y_scale = 13;
503 hb_font_get_scale (font, NULL, &y_scale);
504 g_assert_cmpint (y_scale, ==, upem);
505 x_scale = y_scale = 13;
506 hb_font_get_scale (font, &x_scale, &y_scale);
507 g_assert_cmpint (x_scale, ==, upem);
508 g_assert_cmpint (y_scale, ==, upem);
509
510 hb_font_set_scale (font, 17, 19);
511
512 x_scale = y_scale = 13;
513 hb_font_get_scale (font, &x_scale, &y_scale);
514 g_assert_cmpint (x_scale, ==, 17);
515 g_assert_cmpint (y_scale, ==, 19);
516
517
518 /* Check ppem */
519
520 hb_font_get_ppem (font, NULL, NULL);
521 x_ppem = y_ppem = 13;
522 hb_font_get_ppem (font, &x_ppem, NULL);
523 g_assert_cmpint (x_ppem, ==, 0);
524 x_ppem = y_ppem = 13;
525 hb_font_get_ppem (font, NULL, &y_ppem);
526 g_assert_cmpint (y_ppem, ==, 0);
527 x_ppem = y_ppem = 13;
528 hb_font_get_ppem (font, &x_ppem, &y_ppem);
529 g_assert_cmpint (x_ppem, ==, 0);
530 g_assert_cmpint (y_ppem, ==, 0);
531
532 hb_font_set_ppem (font, 17, 19);
533
534 x_ppem = y_ppem = 13;
535 hb_font_get_ppem (font, &x_ppem, &y_ppem);
536 g_assert_cmpint (x_ppem, ==, 17);
537 g_assert_cmpint (y_ppem, ==, 19);
538
539 /* Check ptem */
540 g_assert_cmpint (hb_font_get_ptem (font), ==, 0);
541 hb_font_set_ptem (font, 42);
542 g_assert_cmpint (hb_font_get_ptem (font), ==, 42);
543
544
545 /* Check immutable */
546
547 g_assert (!hb_font_is_immutable (font));
548 hb_font_make_immutable (font);
549 g_assert (hb_font_is_immutable (font));
550
551 hb_font_set_scale (font, 10, 12);
552 x_scale = y_scale = 13;
553 hb_font_get_scale (font, &x_scale, &y_scale);
554 g_assert_cmpint (x_scale, ==, 17);
555 g_assert_cmpint (y_scale, ==, 19);
556
557 hb_font_set_ppem (font, 10, 12);
558 x_ppem = y_ppem = 13;
559 hb_font_get_ppem (font, &x_ppem, &y_ppem);
560 g_assert_cmpint (x_ppem, ==, 17);
561 g_assert_cmpint (y_ppem, ==, 19);
562
563
564 /* sub_font now */
565 subfont = hb_font_create_sub_font (font);
566 hb_font_destroy (font);
567
568 g_assert (hb_font_get_parent (subfont) == font);
569 g_assert (hb_font_get_face (subfont) == face);
570
571 /* scale */
572 x_scale = y_scale = 13;
573 hb_font_get_scale (subfont, &x_scale, &y_scale);
574 g_assert_cmpint (x_scale, ==, 17);
575 g_assert_cmpint (y_scale, ==, 19);
576 hb_font_set_scale (subfont, 10, 12);
577 x_scale = y_scale = 13;
578 hb_font_get_scale (subfont, &x_scale, &y_scale);
579 g_assert_cmpint (x_scale, ==, 10);
580 g_assert_cmpint (y_scale, ==, 12);
581 x_scale = y_scale = 13;
582 hb_font_get_scale (font, &x_scale, &y_scale);
583 g_assert_cmpint (x_scale, ==, 17);
584 g_assert_cmpint (y_scale, ==, 19);
585
586 /* ppem */
587 x_ppem = y_ppem = 13;
588 hb_font_get_ppem (subfont, &x_ppem, &y_ppem);
589 g_assert_cmpint (x_ppem, ==, 17);
590 g_assert_cmpint (y_ppem, ==, 19);
591 hb_font_set_ppem (subfont, 10, 12);
592 x_ppem = y_ppem = 13;
593 hb_font_get_ppem (subfont, &x_ppem, &y_ppem);
594 g_assert_cmpint (x_ppem, ==, 10);
595 g_assert_cmpint (y_ppem, ==, 12);
596 x_ppem = y_ppem = 13;
597 hb_font_get_ppem (font, &x_ppem, &y_ppem);
598 g_assert_cmpint (x_ppem, ==, 17);
599 g_assert_cmpint (y_ppem, ==, 19);
600
601 hb_font_destroy (subfont);
602 }
603
604 int
main(int argc,char ** argv)605 main (int argc, char **argv)
606 {
607 hb_test_init (&argc, &argv);
608
609 hb_test_add (test_face_empty);
610 hb_test_add (test_face_create);
611 hb_test_add (test_face_createfortables);
612
613 hb_test_add (test_fontfuncs_empty);
614 hb_test_add (test_fontfuncs_nil);
615 hb_test_add (test_fontfuncs_subclassing);
616 hb_test_add (test_fontfuncs_parallels);
617
618 hb_test_add (test_font_empty);
619 hb_test_add (test_font_properties);
620
621 return hb_test_run();
622 }
623