diff --git a/src/hb-ot-post-table-v2subset.hh b/src/hb-ot-post-table-v2subset.hh index 94450eb53..504de2de7 100644 --- a/src/hb-ot-post-table-v2subset.hh +++ b/src/hb-ot-post-table-v2subset.hh @@ -79,6 +79,7 @@ HB_INTERNAL bool postV2Tail::subset (hb_subset_context_t *c) const post::accelerator_t _post; _post.init (c->plan->source); + hb_hashmap_t glyph_name_to_new_index; for (hb_codepoint_t new_gid = 0; new_gid < num_glyphs; new_gid++) { hb_codepoint_t old_gid = reverse_glyph_map.get (new_gid); @@ -90,22 +91,28 @@ HB_INTERNAL bool postV2Tail::subset (hb_subset_context_t *c) const else { hb_bytes_t s = _post.find_glyph_name (old_gid); - int standard_glyph_index = -1; - for (unsigned i = 0; i < format1_names_length; i++) + new_index = glyph_name_to_new_index.get (s); + if (new_index == (unsigned)-1) { - if (s == format1_names (i)) + int standard_glyph_index = -1; + for (unsigned i = 0; i < format1_names_length; i++) { - standard_glyph_index = i; - break; + if (s == format1_names (i)) + { + standard_glyph_index = i; + break; + } } + + if (standard_glyph_index == -1) + { + new_index = 258 + i; + i++; + } + else + { new_index = standard_glyph_index; } + glyph_name_to_new_index.set (s, new_index); } - if (standard_glyph_index == -1) - { - new_index = 258 + i; - i++; - } - else - { new_index = standard_glyph_index; } old_new_index_map.set (old_index, new_index); } old_gid_new_index_map.set (old_gid, new_index); diff --git a/test/subset/data/Makefile.am b/test/subset/data/Makefile.am index d83113bab..f46bc2456 100644 --- a/test/subset/data/Makefile.am +++ b/test/subset/data/Makefile.am @@ -51,6 +51,7 @@ EXTRA_DIST += \ expected/variable \ expected/glyph_names \ expected/math \ + expected/post \ fonts \ profiles \ $(NULL) diff --git a/test/subset/data/Makefile.sources b/test/subset/data/Makefile.sources index e3bf00c66..7a366a3f5 100644 --- a/test/subset/data/Makefile.sources +++ b/test/subset/data/Makefile.sources @@ -43,6 +43,7 @@ TESTS = \ tests/variable.tests \ tests/glyph_names.tests \ tests/math.tests \ + tests/post.tests \ $(NULL) # TODO: re-enable once colrv1 subsetting is stabilized. diff --git a/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.default.c30,c36,c40,c4d.ttf b/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.default.c30,c36,c40,c4d.ttf new file mode 100644 index 000000000..f96e74fd7 Binary files /dev/null and b/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.default.c30,c36,c40,c4d.ttf differ diff --git a/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.default.retain-all-codepoint.ttf b/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.default.retain-all-codepoint.ttf new file mode 100644 index 000000000..1fc3ada45 Binary files /dev/null and b/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.default.retain-all-codepoint.ttf differ diff --git a/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.glyph-names.c30,c36,c40,c4d.ttf b/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.glyph-names.c30,c36,c40,c4d.ttf new file mode 100644 index 000000000..984fde576 Binary files /dev/null and b/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.glyph-names.c30,c36,c40,c4d.ttf differ diff --git a/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.glyph-names.retain-all-codepoint.ttf b/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.glyph-names.retain-all-codepoint.ttf new file mode 100644 index 000000000..e5a279986 Binary files /dev/null and b/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.glyph-names.retain-all-codepoint.ttf differ diff --git a/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.notdef-outline.c30,c36,c40,c4d.ttf b/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.notdef-outline.c30,c36,c40,c4d.ttf new file mode 100644 index 000000000..882fc57b2 Binary files /dev/null and b/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.notdef-outline.c30,c36,c40,c4d.ttf differ diff --git a/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.notdef-outline.retain-all-codepoint.ttf b/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.notdef-outline.retain-all-codepoint.ttf new file mode 100644 index 000000000..d19f57345 Binary files /dev/null and b/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.notdef-outline.retain-all-codepoint.ttf differ diff --git a/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.retain-gids.c30,c36,c40,c4d.ttf b/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.retain-gids.c30,c36,c40,c4d.ttf new file mode 100644 index 000000000..99419f977 Binary files /dev/null and b/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.retain-gids.c30,c36,c40,c4d.ttf differ diff --git a/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.retain-gids.retain-all-codepoint.ttf b/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.retain-gids.retain-all-codepoint.ttf new file mode 100644 index 000000000..5027ded3e Binary files /dev/null and b/test/subset/data/expected/post/SreeKrushnadevaraya-Regular.retain-gids.retain-all-codepoint.ttf differ diff --git a/test/subset/data/fonts/SreeKrushnadevaraya-Regular.ttf b/test/subset/data/fonts/SreeKrushnadevaraya-Regular.ttf new file mode 100644 index 000000000..46207921b Binary files /dev/null and b/test/subset/data/fonts/SreeKrushnadevaraya-Regular.ttf differ diff --git a/test/subset/data/tests/post.tests b/test/subset/data/tests/post.tests new file mode 100644 index 000000000..d6c6a357d --- /dev/null +++ b/test/subset/data/tests/post.tests @@ -0,0 +1,12 @@ +FONTS: +SreeKrushnadevaraya-Regular.ttf + +PROFILES: +default.txt +retain-gids.txt +glyph-names.txt +notdef-outline.txt + +SUBSETS: +U+c30,U+c36,U+c40,U+c4d +* diff --git a/test/subset/meson.build b/test/subset/meson.build index dd53551e8..bfcfa83a9 100644 --- a/test/subset/meson.build +++ b/test/subset/meson.build @@ -45,6 +45,7 @@ tests = [ 'cbdt', 'variable', 'glyph_names', + 'post', ] repack_tests = [