add api test cases for HVAR with index map (and fix)

This commit is contained in:
Michiharu Ariza 2019-03-19 16:00:01 -07:00
parent 0576253a34
commit 1051faf7aa
2 changed files with 71 additions and 7 deletions

View File

@ -170,7 +170,7 @@ struct index_map_subset_plan_t
last_gid = gid; last_gid = gid;
} }
map_count = last_gid + 1; map_count = last_gid;
for (gid = 0; gid < map_count; gid++) for (gid = 0; gid < map_count; gid++)
{ {
hb_codepoint_t old_gid; hb_codepoint_t old_gid;

View File

@ -30,7 +30,68 @@
/* Unit tests for HVAR subsetting */ /* Unit tests for HVAR subsetting */
static void static void
test_subset_HVAR_noop (void) test_subset_map_HVAR_noop (void)
{
hb_face_t *face_abc = hb_test_open_font_file("fonts/AdobeVFPrototype.abc.otf");
hb_set_t *codepoints = hb_set_create ();
hb_face_t *face_abc_subset;
hb_set_add (codepoints, 'a');
hb_set_add (codepoints, 'b');
hb_set_add (codepoints, 'c');
face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
hb_set_destroy (codepoints);
hb_subset_test_check (face_abc, face_abc_subset, HB_TAG ('H','V','A','R'));
hb_face_destroy (face_abc_subset);
hb_face_destroy (face_abc);
}
static void
test_subset_map_HVAR (void)
{
hb_face_t *face_abc = hb_test_open_font_file ("fonts/AdobeVFPrototype.abc.otf");
hb_face_t *face_ac = hb_test_open_font_file ("fonts/AdobeVFPrototype.ac.otf");
hb_set_t *codepoints = hb_set_create ();
hb_face_t *face_abc_subset;
hb_set_add (codepoints, 'a');
hb_set_add (codepoints, 'c');
face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
hb_set_destroy (codepoints);
hb_subset_test_check (face_ac, face_abc_subset, HB_TAG ('H','V','A','R'));
hb_face_destroy (face_abc_subset);
hb_face_destroy (face_abc);
hb_face_destroy (face_ac);
}
static void
test_subset_map_HVAR_retaingids (void)
{
hb_face_t *face_abc = hb_test_open_font_file ("fonts/AdobeVFPrototype.abc.otf");
hb_face_t *face_ac = hb_test_open_font_file ("fonts/AdobeVFPrototype.ac.retaingids.otf");
hb_set_t *codepoints = hb_set_create ();
hb_face_t *face_abc_subset;
hb_set_add (codepoints, 'a');
hb_set_add (codepoints, 'c');
hb_subset_input_t *input = hb_subset_test_create_input (codepoints);
hb_subset_input_set_retain_gids (input, true);
face_abc_subset = hb_subset_test_create_subset (face_abc, input);
hb_set_destroy (codepoints);
hb_subset_test_check (face_ac, face_abc_subset, HB_TAG ('H','V','A','R'));
hb_face_destroy (face_abc_subset);
hb_face_destroy (face_abc);
hb_face_destroy (face_ac);
}
static void
test_subset_identity_HVAR_noop (void)
{ {
hb_face_t *face_abc = hb_test_open_font_file("fonts/SourceSansVariable-Roman.abc.ttf"); hb_face_t *face_abc = hb_test_open_font_file("fonts/SourceSansVariable-Roman.abc.ttf");
@ -49,7 +110,7 @@ test_subset_HVAR_noop (void)
} }
static void static void
test_subset_HVAR (void) test_subset_identity_HVAR (void)
{ {
hb_face_t *face_abc = hb_test_open_font_file ("fonts/SourceSansVariable-Roman.abc.ttf"); hb_face_t *face_abc = hb_test_open_font_file ("fonts/SourceSansVariable-Roman.abc.ttf");
hb_face_t *face_ac = hb_test_open_font_file ("fonts/SourceSansVariable-Roman.ac.ttf"); hb_face_t *face_ac = hb_test_open_font_file ("fonts/SourceSansVariable-Roman.ac.ttf");
@ -69,7 +130,7 @@ test_subset_HVAR (void)
} }
static void static void
test_subset_HVAR_retaingids (void) test_subset_identity_HVAR_retaingids (void)
{ {
hb_face_t *face_abc = hb_test_open_font_file ("fonts/SourceSansVariable-Roman.abc.ttf"); hb_face_t *face_abc = hb_test_open_font_file ("fonts/SourceSansVariable-Roman.abc.ttf");
hb_face_t *face_ac = hb_test_open_font_file ("fonts/SourceSansVariable-Roman.ac.retaingids.ttf"); hb_face_t *face_ac = hb_test_open_font_file ("fonts/SourceSansVariable-Roman.ac.retaingids.ttf");
@ -96,9 +157,12 @@ main (int argc, char **argv)
{ {
hb_test_init (&argc, &argv); hb_test_init (&argc, &argv);
hb_test_add (test_subset_HVAR_noop); hb_test_add (test_subset_map_HVAR_noop);
hb_test_add (test_subset_HVAR); hb_test_add (test_subset_map_HVAR);
hb_test_add (test_subset_HVAR_retaingids); hb_test_add (test_subset_map_HVAR_retaingids);
hb_test_add (test_subset_identity_HVAR_noop);
hb_test_add (test_subset_identity_HVAR);
hb_test_add (test_subset_identity_HVAR_retaingids);
return hb_test_run (); return hb_test_run ();
} }