From aca55dbe36eafb0f69081323b679f2a5bf51239c Mon Sep 17 00:00:00 2001 From: Qunxin Liu Date: Fri, 3 Nov 2023 10:51:37 -0700 Subject: [PATCH] [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