[subset] Subsetting Name Table Step 4
Add unit test and integration test
diff --git a/test/api/Makefile.am b/test/api/Makefile.am
index 67d66e1..9d7b319 100644
--- a/test/api/Makefile.am
+++ b/test/api/Makefile.am
@@ -52,6 +52,7 @@
test-subset-cff2 \
test-unicode \
test-version \
+ test-subset-nameids \
$(NULL)
test_subset_LDADD = $(LDADD) $(top_builddir)/src/libharfbuzz-subset.la
@@ -64,6 +65,7 @@
test_subset_vmtx_LDADD = $(LDADD) $(top_builddir)/src/libharfbuzz-subset.la
test_subset_cff1_LDADD = $(LDADD) $(top_builddir)/src/libharfbuzz-subset.la
test_subset_cff2_LDADD = $(LDADD) $(top_builddir)/src/libharfbuzz-subset.la
+test_subset_nameids_LDADD = $(LDADD) $(top_builddir)/src/libharfbuzz-subset.la
test_unicode_CPPFLAGS = \
$(AM_CPPFLAGS) \
diff --git a/test/api/fonts/nameID.expected.ttf b/test/api/fonts/nameID.expected.ttf
new file mode 100644
index 0000000..ccd4b8b
--- /dev/null
+++ b/test/api/fonts/nameID.expected.ttf
Binary files differ
diff --git a/test/api/fonts/nameID.origin.ttf b/test/api/fonts/nameID.origin.ttf
new file mode 100644
index 0000000..aec973a
--- /dev/null
+++ b/test/api/fonts/nameID.origin.ttf
Binary files differ
diff --git a/test/api/hb-subset-test.h b/test/api/hb-subset-test.h
index 3e759a8..8f32aee 100644
--- a/test/api/hb-subset-test.h
+++ b/test/api/hb-subset-test.h
@@ -65,6 +65,15 @@
return input;
}
+static inline hb_subset_input_t *
+hb_subset_test_create_input_from_nameids (const hb_set_t *name_ids)
+{
+ hb_subset_input_t *input = hb_subset_input_create_or_fail ();
+ hb_set_t * input_name_ids = hb_subset_input_nameid_set (input);
+ hb_set_union (input_name_ids, name_ids);
+ return input;
+}
+
static inline hb_face_t *
hb_subset_test_create_subset (hb_face_t *source,
hb_subset_input_t *input)
diff --git a/test/api/test-subset-nameids.c b/test/api/test-subset-nameids.c
new file mode 100644
index 0000000..0057a7b
--- /dev/null
+++ b/test/api/test-subset-nameids.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright © 2018 Google, Inc.
+ *
+ * This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Google Author(s): Garret Rieger
+ */
+
+#include "hb-test.h"
+#include "hb-subset-test.h"
+
+static void
+test_subset_nameids (void)
+{
+ hb_face_t *face_origin = hb_test_open_font_file ("fonts/nameID.origin.ttf");
+ hb_face_t *face_expected = hb_test_open_font_file ("fonts/nameID.expected.ttf");
+
+ hb_set_t *name_ids = hb_set_create();
+ hb_face_t *face_subset;
+ hb_set_add (name_ids, 0);
+ hb_set_add (name_ids, 9);
+ face_subset = hb_subset_test_create_subset (face_origin, hb_subset_test_create_input_from_nameids (name_ids));
+ hb_set_destroy (name_ids);
+
+ hb_subset_test_check (face_expected, face_subset, HB_TAG ('n','a','m','e'));
+
+ hb_face_destroy (face_subset);
+ hb_face_destroy (face_origin);
+ hb_face_destroy (face_expected);
+}
+
+int
+main (int argc, char **argv)
+{
+ hb_test_init (&argc, &argv);
+
+ hb_test_add (test_subset_nameids);
+
+ return hb_test_run();
+}
diff --git a/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.61,62,63.ttf b/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.61,62,63.ttf
new file mode 100644
index 0000000..12d9208
--- /dev/null
+++ b/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.61,62,63.ttf
Binary files differ
diff --git a/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.61,63.ttf b/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.61,63.ttf
new file mode 100644
index 0000000..1af233f
--- /dev/null
+++ b/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.61,63.ttf
Binary files differ
diff --git a/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.61.ttf b/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.61.ttf
new file mode 100644
index 0000000..a699eea
--- /dev/null
+++ b/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.61.ttf
Binary files differ
diff --git a/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.62.ttf b/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.62.ttf
new file mode 100644
index 0000000..52706dc
--- /dev/null
+++ b/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.62.ttf
Binary files differ
diff --git a/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.63.ttf b/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.63.ttf
new file mode 100644
index 0000000..3de7c77
--- /dev/null
+++ b/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.63.ttf
Binary files differ
diff --git a/test/subset/data/profiles/name-ids.txt b/test/subset/data/profiles/name-ids.txt
new file mode 100644
index 0000000..db42c09
--- /dev/null
+++ b/test/subset/data/profiles/name-ids.txt
@@ -0,0 +1 @@
+--name-IDs=0,1,2
diff --git a/test/subset/data/tests/basics.tests b/test/subset/data/tests/basics.tests
index 4fc3f4e..794510d 100644
--- a/test/subset/data/tests/basics.tests
+++ b/test/subset/data/tests/basics.tests
@@ -6,6 +6,7 @@
drop-hints.txt
drop-hints-retain-gids.txt
retain-gids.txt
+name-ids.txt
SUBSETS:
abc