diff --git a/test/api/Makefile.am b/test/api/Makefile.am index 67d66e16d2c7b759fc90e79654cebca4686be59a..9d7b3198c589db2e1a6a20befe81e06d39f24279 100644 --- a/test/api/Makefile.am +++ b/test/api/Makefile.am @@ -52,6 +52,7 @@ TEST_PROGS = \ 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_post_LDADD = $(LDADD) $(top_builddir)/src/libharfbuzz-subset.la 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 0000000000000000000000000000000000000000..ccd4b8bcd26816e7ffcd6afa58306373bc0534d9 Binary files /dev/null and b/test/api/fonts/nameID.expected.ttf differ diff --git a/test/api/fonts/nameID.origin.ttf b/test/api/fonts/nameID.origin.ttf new file mode 100644 index 0000000000000000000000000000000000000000..aec973a580361724e4fc69b5a54b51c9cd711d6e Binary files /dev/null and b/test/api/fonts/nameID.origin.ttf differ diff --git a/test/api/hb-subset-test.h b/test/api/hb-subset-test.h index 3e759a8a97220d13bf486b304fddc27583a586de..8f32aee6795908e07e8808acf637c390571c1356 100644 --- a/test/api/hb-subset-test.h +++ b/test/api/hb-subset-test.h @@ -65,6 +65,15 @@ hb_subset_test_create_input_from_glyphs (const hb_set_t *glyphs) 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 0000000000000000000000000000000000000000..0057a7b75e85dd9b6e277d676a17b3d85ee5c86e --- /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 0000000000000000000000000000000000000000..12d92081b31eda6deaf2aa8b62e69c0535dfe225 Binary files /dev/null and b/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.61,62,63.ttf 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 0000000000000000000000000000000000000000..1af233f482d63226cf4cb10e502e243b83c6fa4e Binary files /dev/null and b/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.61,63.ttf 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 0000000000000000000000000000000000000000..a699eea0bced6d31e273e28487cb5292da5bc78b Binary files /dev/null and b/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.61.ttf 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 0000000000000000000000000000000000000000..52706dc90320133d24a0a6c3109b9d1ef1bf8ec7 Binary files /dev/null and b/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.62.ttf 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 0000000000000000000000000000000000000000..3de7c7734f88cc537915222a2fd265cf19a4f450 Binary files /dev/null and b/test/subset/data/expected/basics/Roboto-Regular.abc.name-ids.63.ttf differ diff --git a/test/subset/data/profiles/name-ids.txt b/test/subset/data/profiles/name-ids.txt new file mode 100644 index 0000000000000000000000000000000000000000..db42c09a45789558b36eb992f5cdf47e1e6c6d6f --- /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 4fc3f4ebad7f10664b5458c0f3c5662850b2c8f7..794510d87c01b9bc36f175c2bdf9f16e66498121 100644 --- a/test/subset/data/tests/basics.tests +++ b/test/subset/data/tests/basics.tests @@ -6,6 +6,7 @@ default.txt drop-hints.txt drop-hints-retain-gids.txt retain-gids.txt +name-ids.txt SUBSETS: abc