add api test for tt var advance widths

stripped HVAR from SourceSansVariable-Roman.abc.ttf so glyf gets parsed
This commit is contained in:
Michiharu Ariza 2019-03-18 15:39:10 -07:00
parent 9d9d5c706b
commit 9d3a252030
3 changed files with 37 additions and 1 deletions

View File

@ -221,7 +221,6 @@ struct hmtxvmtx
var_table.destroy (); var_table.destroy ();
} }
/* TODO Add variations version. */
int get_side_bearing (hb_codepoint_t glyph) const int get_side_bearing (hb_codepoint_t glyph) const
{ {
if (glyph < num_advances) if (glyph < num_advances)

View File

@ -61,12 +61,49 @@ test_extents_tt_var (void)
hb_font_destroy (font); hb_font_destroy (font);
} }
static void
test_advance_tt_var (void)
{
hb_face_t *face = hb_test_open_font_file ("fonts/SourceSansVariable-Roman.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, ==, 486);
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] = { 500.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, ==, 510);
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);
hb_font_destroy (font);
}
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
hb_test_init (&argc, &argv); hb_test_init (&argc, &argv);
hb_test_add (test_extents_tt_var); hb_test_add (test_extents_tt_var);
hb_test_add (test_advance_tt_var);
return hb_test_run (); return hb_test_run ();
} }