From a84cae424d7b315336a191d13a2bef8a9d3635d2 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 15 Mar 2023 02:39:57 +0000 Subject: [PATCH] [subset] Don't add invalid gids (-1) to the glyphset when loading glyph map from the accelerator. --- src/OT/Layout/GPOS/PairPosFormat1.hh | 2 +- src/hb-subset-plan.cc | 9 ++++++--- test/subset/data/Makefile.am | 1 + test/subset/data/Makefile.sources | 1 + .../Roboto-Regular.gids.61,62,63,30D9.ttf | Bin 0 -> 2680 bytes test/subset/data/tests/preprocess.tests | 8 ++++++++ test/subset/meson.build | 1 + 7 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 test/subset/data/expected/preprocess/Roboto-Regular.gids.61,62,63,30D9.ttf create mode 100644 test/subset/data/tests/preprocess.tests diff --git a/src/OT/Layout/GPOS/PairPosFormat1.hh b/src/OT/Layout/GPOS/PairPosFormat1.hh index b4a9a9ad5..4dada1c83 100644 --- a/src/OT/Layout/GPOS/PairPosFormat1.hh +++ b/src/OT/Layout/GPOS/PairPosFormat1.hh @@ -55,7 +55,7 @@ struct PairPosFormat1_3 if (pairSet.len > glyphs->get_population () * hb_bit_storage ((unsigned) pairSet.len) / 4) { - for (hb_codepoint_t g = HB_SET_VALUE_INVALID; glyphs->next (&g);) + for (hb_codepoint_t g : glyphs->iter()) { unsigned i = cov.get_coverage (g); if ((this+pairSet[i]).intersects (glyphs, valueFormat)) diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 5ac22e7c8..3a2d5081f 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -556,9 +556,12 @@ _populate_unicodes_to_retain (const hb_set_t *unicodes, if (plan->codepoint_to_glyph->has (cp)) continue; - hb_codepoint_t gid = (*unicode_glyphid_map)[cp]; - plan->codepoint_to_glyph->set (cp, gid); - plan->unicode_to_new_gid_list.push (hb_pair (cp, gid)); + hb_codepoint_t *gid; + if (!unicode_glyphid_map->has(cp, &gid)) + continue; + + plan->codepoint_to_glyph->set (cp, *gid); + plan->unicode_to_new_gid_list.push (hb_pair (cp, *gid)); } plan->unicode_to_new_gid_list.qsort (); } diff --git a/test/subset/data/Makefile.am b/test/subset/data/Makefile.am index 864db2d86..e13053ee5 100644 --- a/test/subset/data/Makefile.am +++ b/test/subset/data/Makefile.am @@ -10,6 +10,7 @@ EXTRA_DIST += \ $(DISABLED_TESTS) \ expected/32bit_var_store \ expected/basics \ + expected/preprocess \ expected/full-font \ expected/glyf_bug_3131 \ expected/cff-full-font \ diff --git a/test/subset/data/Makefile.sources b/test/subset/data/Makefile.sources index 6437c00d3..22367f958 100644 --- a/test/subset/data/Makefile.sources +++ b/test/subset/data/Makefile.sources @@ -1,6 +1,7 @@ TESTS = \ tests/32bit_var_store.tests \ tests/basics.tests \ + tests/preprocess.tests \ tests/cbdt.tests \ tests/cff-full-font.tests \ tests/cff-japanese.tests \ diff --git a/test/subset/data/expected/preprocess/Roboto-Regular.gids.61,62,63,30D9.ttf b/test/subset/data/expected/preprocess/Roboto-Regular.gids.61,62,63,30D9.ttf new file mode 100644 index 0000000000000000000000000000000000000000..5f8bff0adeba00433798fbac0bdc644f1a71c209 GIT binary patch literal 2680 zcmZuyeQaA-6+idA=WjQ8Hg4S7ZSov9UyWU-N$Pf4)McBUGz1baN!fGMwef7{ql*(S zak6xxQ1;OUuOAdT4RvfFKrjlT*JjXU9a1DZ5TK0#8=?p%A?=TWiU4U$Q%7yid3Ne< z;y%4|&+mMnbFZI)0e~He1WI2h+zW$X0bqYdX>(s>Xhe78A6Egy4B}ILBM0yK%BIHz z06{|BIW!Vz&ln!7LcIg=csvzL!`l!*eH!s#d?}-}zG!$J@jBwsiS%UZkq^ed51=2% z9Is5q7SdpZPay9@y>)Wt*hFy4J1+njx1rD2R3f!pWiZ)Me*pE4sbnni-=n{K6m|O$ z2d7YAep&Zj)UP7mF_p?J+t08y#D@@Xo0*Hp;2I-6*~_Wea$49cnh-A|R%Tn@ zlk>@kz%>)g%z{gcLSq8#o)-B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&{ z9W`RJZ2rQJzVRAke|stOaQx)U3$HF+c~fdESnmIt_gvuz8D;q7kDvbDm4mT`MBjbS zs#m^UsCq_~PmdjV`xo~=NFVo8#p{xSe*{&q6(;g_mz&D7%Ur~sjRCDwD>i4{Xj?=e zZnUjOpr^KVMv>Y!TWRA~IcKl5!$mpgtiZP2%prK|n+#rChb^esZB5jm!B*4J9+Z@K z)?Z7TF0Q3n_OEMS{^I4x!Iz#qFW5dP{Qlf=J>2}+(}h12Zt8ye`o)6p;_LWDKZGZC z9ZzgK4CLk7I!s4(!#{d(Pd J5U literal 0 HcmV?d00001 diff --git a/test/subset/data/tests/preprocess.tests b/test/subset/data/tests/preprocess.tests new file mode 100644 index 000000000..ba2a0e2d2 --- /dev/null +++ b/test/subset/data/tests/preprocess.tests @@ -0,0 +1,8 @@ +FONTS: +Roboto-Regular.ttf + +PROFILES: +gids.txt + +SUBSETS: +abcベ diff --git a/test/subset/meson.build b/test/subset/meson.build index 4f360a34f..289cc1649 100644 --- a/test/subset/meson.build +++ b/test/subset/meson.build @@ -1,5 +1,6 @@ tests = [ 'basics', + 'preprocess', 'full-font', 'cff-full-font', 'japanese',