add HVAR & VVAR advance width api test

This commit is contained in:
Michiharu Ariza 2019-03-22 11:05:23 -07:00
parent ae3db1f4e3
commit 9c5d694af2
1 changed files with 39 additions and 2 deletions

View File

@ -62,7 +62,7 @@ test_extents_tt_var (void)
}
static void
test_advance_tt_var (void)
test_advance_tt_var_nohvar (void)
{
hb_face_t *face = hb_test_open_font_file ("fonts/SourceSansVariable-Roman-nohvar-41,C1.ttf");
g_assert (face);
@ -97,13 +97,50 @@ test_advance_tt_var (void)
hb_font_destroy (font);
}
static void
test_advance_tt_var_hvarvvar (void)
{
hb_face_t *face = hb_test_open_font_file ("fonts/SourceSerifVariable-Roman-VVAR.abc.ttf");
g_assert (face);
hb_font_t *font = hb_font_create (face);
hb_face_destroy (face);
g_assert (font);
hb_ot_font_set_funcs (font);
hb_position_t x, y;
hb_font_get_glyph_advance_for_direction(font, 1, HB_DIRECTION_LTR, &x, &y);
g_assert_cmpint (x, ==, 508);
g_assert_cmpint (y, ==, 0);
hb_font_get_glyph_advance_for_direction(font, 1, HB_DIRECTION_TTB, &x, &y);
g_assert_cmpint (x, ==, 0);
g_assert_cmpint (y, ==, -1000);
float coords[1] = { 700.0f };
hb_font_set_var_coords_design (font, coords, 1);
hb_font_get_glyph_advance_for_direction(font, 1, HB_DIRECTION_LTR, &x, &y);
g_assert_cmpint (x, ==, 531);
g_assert_cmpint (y, ==, 0);
hb_font_get_glyph_advance_for_direction(font, 1, HB_DIRECTION_TTB, &x, &y);
g_assert_cmpint (x, ==, 0);
g_assert_cmpint (y, ==, -1012);
hb_font_destroy (font);
}
int
main (int argc, char **argv)
{
hb_test_init (&argc, &argv);
hb_test_add (test_extents_tt_var);
hb_test_add (test_advance_tt_var);
hb_test_add (test_advance_tt_var_nohvar);
hb_test_add (test_advance_tt_var_hvarvvar);
return hb_test_run ();
}