From 94ef1a703ff20614538680587a23cec5f1649189 Mon Sep 17 00:00:00 2001 From: Michiharu Ariza Date: Fri, 22 Mar 2019 11:05:23 -0700 Subject: [PATCH] add HVAR & VVAR advance width api test --- test/api/test-ot-metrics-tt-var.c | 41 +++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/test/api/test-ot-metrics-tt-var.c b/test/api/test-ot-metrics-tt-var.c index 334f3cd93..56d4b1159 100644 --- a/test/api/test-ot-metrics-tt-var.c +++ b/test/api/test-ot-metrics-tt-var.c @@ -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 (); }