From aca55dbe36eafb0f69081323b679f2a5bf51239c Mon Sep 17 00:00:00 2001 From: Qunxin Liu Date: Fri, 3 Nov 2023 10:51:37 -0700 Subject: [PATCH 1/2] [instancer] fix feature variations collect lookups We already know which record to keep, so just collect lookups and no need to check the substitutes_map --- src/hb-ot-layout-common.hh | 12 ++---------- src/hb-ot-layout-gsubgpos.hh | 3 +-- src/hb-ot-layout.cc | 2 +- src/hb-subset-plan.cc | 2 +- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 2d8f42a16..bc3c12cf2 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -3645,16 +3645,10 @@ struct FeatureTableSubstitution } void collect_lookups (const hb_set_t *feature_indexes, - const hb_hashmap_t *feature_substitutes_map, hb_set_t *lookup_indexes /* OUT */) const { + hb_iter (substitutions) | hb_filter (feature_indexes, &FeatureTableSubstitutionRecord::featureIndex) - | hb_filter ([feature_substitutes_map] (const FeatureTableSubstitutionRecord& record) - { - if (feature_substitutes_map == nullptr) return true; - return !feature_substitutes_map->has (record.featureIndex); - }) | hb_apply ([this, lookup_indexes] (const FeatureTableSubstitutionRecord& r) { r.collect_lookups (this, lookup_indexes); }) ; @@ -3740,10 +3734,9 @@ struct FeatureVariationRecord void collect_lookups (const void *base, const hb_set_t *feature_indexes, - const hb_hashmap_t *feature_substitutes_map, hb_set_t *lookup_indexes /* OUT */) const { - return (base+substitutions).collect_lookups (feature_indexes, feature_substitutes_map, lookup_indexes); + return (base+substitutions).collect_lookups (feature_indexes, lookup_indexes); } void closure_features (const void *base, @@ -3847,7 +3840,6 @@ struct FeatureVariations } void collect_lookups (const hb_set_t *feature_indexes, - const hb_hashmap_t *feature_substitutes_map, const hb_hashmap_t> *feature_record_cond_idx_map, hb_set_t *lookup_indexes /* OUT */) const { @@ -3857,7 +3849,7 @@ struct FeatureVariations if (feature_record_cond_idx_map && !feature_record_cond_idx_map->has (i)) continue; - varRecords[i].collect_lookups (this, feature_indexes, feature_substitutes_map, lookup_indexes); + varRecords[i].collect_lookups (this, feature_indexes, lookup_indexes); } } diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 73feb2f2b..c8b531210 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -4631,12 +4631,11 @@ struct GSUBGPOS } void feature_variation_collect_lookups (const hb_set_t *feature_indexes, - const hb_hashmap_t *feature_substitutes_map, const hb_hashmap_t> *feature_record_cond_idx_map, hb_set_t *lookup_indexes /* OUT */) const { #ifndef HB_NO_VAR - get_feature_variations ().collect_lookups (feature_indexes, feature_substitutes_map, feature_record_cond_idx_map, lookup_indexes); + get_feature_variations ().collect_lookups (feature_indexes, feature_record_cond_idx_map, lookup_indexes); #endif } diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index d92b77300..2eb8535db 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -1362,7 +1362,7 @@ hb_ot_layout_collect_lookups (hb_face_t *face, for (auto feature_index : feature_indexes) g.get_feature (feature_index).add_lookup_indexes_to (lookup_indexes); - g.feature_variation_collect_lookups (&feature_indexes, nullptr, nullptr, lookup_indexes); + g.feature_variation_collect_lookups (&feature_indexes, nullptr, lookup_indexes); } diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index c6a5bfc68..b1398e579 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -224,7 +224,7 @@ static void _collect_layout_indices (hb_subset_plan_t *plan, // If all axes are pinned then all feature variations will be dropped so there's no need // to collect lookups from them. if (!plan->all_axes_pinned) - table.feature_variation_collect_lookups (feature_indices, feature_substitutes_map, + table.feature_variation_collect_lookups (feature_indices, plan->user_axes_location.is_empty () ? nullptr: feature_record_cond_idx_map, lookup_indices); #endif From 6baf791e6f5ef38f18876aa952a506858c383c0e Mon Sep 17 00:00:00 2001 From: Qunxin Liu Date: Fri, 3 Nov 2023 11:06:07 -0700 Subject: [PATCH 2/2] [instancer] add tests --- ...t.default.retain-all-codepoint.wdth=112.5.ttf | Bin 0 -> 2668 bytes .../data/fonts/AnekBangla-question-subset.ttf | Bin 0 -> 4488 bytes ...ture_variation_instance_collect_lookups.tests | 11 +++++++++++ test/subset/meson.build | 1 + 4 files changed, 12 insertions(+) create mode 100644 test/subset/data/expected/feature_variation_instance_collect_lookups/AnekBangla-question-subset.default.retain-all-codepoint.wdth=112.5.ttf create mode 100644 test/subset/data/fonts/AnekBangla-question-subset.ttf create mode 100644 test/subset/data/tests/feature_variation_instance_collect_lookups.tests diff --git a/test/subset/data/expected/feature_variation_instance_collect_lookups/AnekBangla-question-subset.default.retain-all-codepoint.wdth=112.5.ttf b/test/subset/data/expected/feature_variation_instance_collect_lookups/AnekBangla-question-subset.default.retain-all-codepoint.wdth=112.5.ttf new file mode 100644 index 0000000000000000000000000000000000000000..2b980d5809f7dcff7d1edec5ba41adb211f215e9 GIT binary patch literal 2668 zcmai03rtg282)d2`=CI<(n3X)s+GB_fJG1$q%8_WQBcqkF<_C}BCi7V8C00lIp(HY zHkU1mZf3+}J~Lz7+!ixs>M)C$b2`n8GrEZ}FclC4?Y?twdAOPEKe^}r-+%u1J?FH< z5m5*xo?_FpvvNxEmney(;~{-FJ!g^aL~q9h;FG|O8H=q8Uy+S66G`fT)3b77%EGC=BfLjPcW=5gR|==|bx*oz~b^~hI}f%OCz1c851 z7}m}L8(rm|wE<7LSAlbZ1Ij9w+bM}^fir=X<@U91lG8-sWx$3Cd%0ug*_uQm#YOmR zbXV4Ryn6}ta&>IoUF~qYNk!=0&EmX-m_;zGIbuCiu5r3NRE&@vaBE=tti42jXM1DO_ic!nFKrc~ zvc-Oq`Xn4FPt$3-M3=g5(H{@~rbo$4MYl-*mg$R$yDVf8Em*cJGc9J8ffoD2fH#l9 za0==bX7Bd{o>?Bv$4_0(E(}WQB&p&OH0XEl^sm|bW=!vQl;~}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w}op|sTM{uXds^Vb9Ul;p5y&7VKd;`#P< zhr_XRm)R78>*_k^>F((6={9D$-O*|3i|gv@7N@60yPa&uj(O4)(I*~L%7BzERjQBn zb)WrvA<}%VI4r)Ul;e_Knj{rUo1{%ajZZuSJkeMnHAowj(tz}N!C{Ybxiy|Eiz!~s>*_g%Q@XFosP?pCYS zeP4$Uwx4ak)a&v2h6b+pU%Pg#|N6j?&zbt&cb!LG1opRfx_YnnUijwF{(ZnFr~52@ zeeLJkfOG9#GN{=Rr%6moHV&FYVOy;?N9t87Rb;fJ35^PmjMi+^;eQ2I!#|2gQ?=Td zM4mRb5NSvwFG; zwq3A|ZlCvZAGhuDXw<_)f*{*gJ*I+PXX@FreP8YY4xaBFbh%w!C%-tz^Xlk@8#b4# s>ry*#sq2ai+V6wW^8!3%IheR{#J2 literal 0 HcmV?d00001 diff --git a/test/subset/data/tests/feature_variation_instance_collect_lookups.tests b/test/subset/data/tests/feature_variation_instance_collect_lookups.tests new file mode 100644 index 000000000..2c45826e3 --- /dev/null +++ b/test/subset/data/tests/feature_variation_instance_collect_lookups.tests @@ -0,0 +1,11 @@ +FONTS: +AnekBangla-question-subset.ttf + +PROFILES: +default.txt + +SUBSETS: +* + +INSTANCES: +wdth=112.5 diff --git a/test/subset/meson.build b/test/subset/meson.build index cbb2cb8e6..331111c0a 100644 --- a/test/subset/meson.build +++ b/test/subset/meson.build @@ -77,6 +77,7 @@ if get_option('experimental_api') 'feature_variations_partial_instance', 'gdef_partial_instance', 'value_format_partial_instance', + 'feature_variation_instance_collect_lookups', ] endif