[subset] Add unit test for glyf subsetting and retain gids.
authorGarret Rieger <grieger@google.com>
Sat, 19 Jan 2019 01:36:32 +0000 (17:36 -0800)
committerGarret Rieger <grieger@google.com>
Tue, 29 Jan 2019 21:19:21 +0000 (13:19 -0800)
test/api/fonts/Roboto-Regular.ac.retaingids.ttf [new file with mode: 0644]
test/api/test-subset-glyf.c

diff --git a/test/api/fonts/Roboto-Regular.ac.retaingids.ttf b/test/api/fonts/Roboto-Regular.ac.retaingids.ttf
new file mode 100644 (file)
index 0000000..8606a55
Binary files /dev/null and b/test/api/fonts/Roboto-Regular.ac.retaingids.ttf differ
index 0e5c293..e8609ca 100644 (file)
@@ -257,6 +257,31 @@ test_subset_glyf_strip_hints_invalid (void)
   hb_face_destroy (face);
 }
 
+static void
+test_subset_glyf_retain_gids (void)
+{
+  hb_face_t *face_abc = hb_test_open_font_file ("fonts/Roboto-Regular.abc.ttf");
+  hb_face_t *face_ac = hb_test_open_font_file ("fonts/Roboto-Regular.ac.retaingids.ttf");
+
+  hb_set_t *codepoints = hb_set_create();
+  hb_face_t *face_abc_subset;
+  hb_set_add (codepoints, 97);
+  hb_set_add (codepoints, 99);
+
+  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 ('g','l','y','f'));
+  hb_subset_test_check (face_ac, face_abc_subset, HB_TAG ('l','o','c', 'a'));
+  check_maxp_num_glyphs(face_abc_subset, 4, true);
+
+  hb_face_destroy (face_abc_subset);
+  hb_face_destroy (face_abc);
+  hb_face_destroy (face_ac);
+}
+
 // TODO(grieger): test for long loca generation.
 
 int
@@ -272,6 +297,7 @@ main (int argc, char **argv)
   hb_test_add (test_subset_glyf_with_components);
   hb_test_add (test_subset_glyf_with_gsub);
   hb_test_add (test_subset_glyf_without_gsub);
+  hb_test_add (test_subset_glyf_retain_gids);
 
   return hb_test_run();
 }