diff options
Diffstat (limited to 'test/api/test-font.c')
-rw-r--r-- | test/api/test-font.c | 88 |
1 files changed, 80 insertions, 8 deletions
diff --git a/test/api/test-font.c b/test/api/test-font.c index 527dfcd..6690194 100644 --- a/test/api/test-font.c +++ b/test/api/test-font.c @@ -83,7 +83,7 @@ free_up (void *user_data) } static hb_blob_t * -get_table (hb_face_t *face, hb_tag_t tag, void *user_data) +get_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data HB_UNUSED) { if (tag == HB_TAG ('a','b','c','d')) return hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL); @@ -210,10 +210,10 @@ test_fontfuncs_nil (void) } static hb_bool_t -contour_point_func1 (hb_font_t *font, void *font_data, - hb_codepoint_t glyph, unsigned int point_index, +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) + void *user_data HB_UNUSED) { if (glyph == 1) { *x = 2; @@ -230,10 +230,10 @@ contour_point_func1 (hb_font_t *font, void *font_data, } static hb_bool_t -contour_point_func2 (hb_font_t *font, void *font_data, +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) + void *user_data HB_UNUSED) { if (glyph == 1) { *x = 6; @@ -246,9 +246,9 @@ contour_point_func2 (hb_font_t *font, void *font_data, } static hb_position_t -glyph_h_advance_func1 (hb_font_t *font, void *font_data, +glyph_h_advance_func1 (hb_font_t *font HB_UNUSED, void *font_data HB_UNUSED, hb_codepoint_t glyph, - void *user_data) + void *user_data HB_UNUSED) { if (glyph == 1) return 8; @@ -361,8 +361,74 @@ test_fontfuncs_subclassing (void) hb_font_destroy (font3); + hb_font_destroy (font2); +} + +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) +{ + *glyph = 0; + return FALSE; +} + +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) +{ + return 0; } +static void +test_fontfuncs_parallels (void) +{ + hb_blob_t *blob; + hb_face_t *face; + + hb_font_funcs_t *ffuncs1; + hb_font_funcs_t *ffuncs2; + + hb_font_t *font0; + hb_font_t *font1; + hb_font_t *font2; + hb_codepoint_t glyph; + + blob = hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL); + face = hb_face_create (blob, 0); + hb_blob_destroy (blob); + font0 = hb_font_create (face); + hb_face_destroy (face); + + /* setup sub-font1 */ + font1 = hb_font_create_sub_font (font0); + hb_font_destroy (font0); + ffuncs1 = hb_font_funcs_create (); + hb_font_funcs_set_nominal_glyph_func (ffuncs1, nominal_glyph_func, NULL, NULL); + hb_font_set_funcs (font1, ffuncs1, NULL, NULL); + hb_font_funcs_destroy (ffuncs1); + + /* setup sub-font2 */ + font2 = hb_font_create_sub_font (font1); + hb_font_destroy (font1); + ffuncs2 = hb_font_funcs_create (); + hb_font_funcs_set_nominal_glyphs_func (ffuncs1, nominal_glyphs_func, NULL, NULL); + hb_font_set_funcs (font2, ffuncs2, NULL, NULL); + hb_font_funcs_destroy (ffuncs2); + + /* Just test that calling get_nominal_glyph doesn't infinite-loop. */ + hb_font_get_nominal_glyph (font2, 0x0020u, &glyph); + + hb_font_destroy (font2); +} static void test_font_empty (void) @@ -470,6 +536,11 @@ test_font_properties (void) g_assert_cmpint (x_ppem, ==, 17); g_assert_cmpint (y_ppem, ==, 19); + /* Check ptem */ + g_assert_cmpint (hb_font_get_ptem (font), ==, 0); + hb_font_set_ptem (font, 42); + g_assert_cmpint (hb_font_get_ptem (font), ==, 42); + /* Check immutable */ @@ -542,6 +613,7 @@ main (int argc, char **argv) hb_test_add (test_fontfuncs_empty); hb_test_add (test_fontfuncs_nil); hb_test_add (test_fontfuncs_subclassing); + hb_test_add (test_fontfuncs_parallels); hb_test_add (test_font_empty); hb_test_add (test_font_properties); |