Merge pull request #4477 from googlefonts/fix_feature_variations

[instancer] Fix feature variations collect lookups
pull/4481/head
Behdad Esfahbod 1 year ago committed by GitHub
commit fd5eb10d3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/hb-ot-layout-common.hh
  2. 3
      src/hb-ot-layout-gsubgpos.hh
  3. 2
      src/hb-ot-layout.cc
  4. 2
      src/hb-subset-plan.cc
  5. BIN
      test/subset/data/expected/feature_variation_instance_collect_lookups/AnekBangla-question-subset.default.retain-all-codepoint.wdth=112.5.ttf
  6. BIN
      test/subset/data/fonts/AnekBangla-question-subset.ttf
  7. 11
      test/subset/data/tests/feature_variation_instance_collect_lookups.tests
  8. 1
      test/subset/meson.build

@ -3645,16 +3645,10 @@ struct FeatureTableSubstitution
} }
void collect_lookups (const hb_set_t *feature_indexes, void collect_lookups (const hb_set_t *feature_indexes,
const hb_hashmap_t<unsigned, const Feature*> *feature_substitutes_map,
hb_set_t *lookup_indexes /* OUT */) const hb_set_t *lookup_indexes /* OUT */) const
{ {
+ hb_iter (substitutions) + hb_iter (substitutions)
| hb_filter (feature_indexes, &FeatureTableSubstitutionRecord::featureIndex) | 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) | hb_apply ([this, lookup_indexes] (const FeatureTableSubstitutionRecord& r)
{ r.collect_lookups (this, lookup_indexes); }) { r.collect_lookups (this, lookup_indexes); })
; ;
@ -3740,10 +3734,9 @@ struct FeatureVariationRecord
void collect_lookups (const void *base, void collect_lookups (const void *base,
const hb_set_t *feature_indexes, const hb_set_t *feature_indexes,
const hb_hashmap_t<unsigned, const Feature*> *feature_substitutes_map,
hb_set_t *lookup_indexes /* OUT */) const 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, void closure_features (const void *base,
@ -3847,7 +3840,6 @@ struct FeatureVariations
} }
void collect_lookups (const hb_set_t *feature_indexes, void collect_lookups (const hb_set_t *feature_indexes,
const hb_hashmap_t<unsigned, const Feature*> *feature_substitutes_map,
const hb_hashmap_t<unsigned, hb::shared_ptr<hb_set_t>> *feature_record_cond_idx_map, const hb_hashmap_t<unsigned, hb::shared_ptr<hb_set_t>> *feature_record_cond_idx_map,
hb_set_t *lookup_indexes /* OUT */) const hb_set_t *lookup_indexes /* OUT */) const
{ {
@ -3857,7 +3849,7 @@ struct FeatureVariations
if (feature_record_cond_idx_map && if (feature_record_cond_idx_map &&
!feature_record_cond_idx_map->has (i)) !feature_record_cond_idx_map->has (i))
continue; continue;
varRecords[i].collect_lookups (this, feature_indexes, feature_substitutes_map, lookup_indexes); varRecords[i].collect_lookups (this, feature_indexes, lookup_indexes);
} }
} }

@ -4631,12 +4631,11 @@ struct GSUBGPOS
} }
void feature_variation_collect_lookups (const hb_set_t *feature_indexes, void feature_variation_collect_lookups (const hb_set_t *feature_indexes,
const hb_hashmap_t<unsigned, const Feature*> *feature_substitutes_map,
const hb_hashmap_t<unsigned, hb::shared_ptr<hb_set_t>> *feature_record_cond_idx_map, const hb_hashmap_t<unsigned, hb::shared_ptr<hb_set_t>> *feature_record_cond_idx_map,
hb_set_t *lookup_indexes /* OUT */) const hb_set_t *lookup_indexes /* OUT */) const
{ {
#ifndef HB_NO_VAR #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 #endif
} }

@ -1362,7 +1362,7 @@ hb_ot_layout_collect_lookups (hb_face_t *face,
for (auto feature_index : feature_indexes) for (auto feature_index : feature_indexes)
g.get_feature (feature_index).add_lookup_indexes_to (lookup_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);
} }

@ -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 // If all axes are pinned then all feature variations will be dropped so there's no need
// to collect lookups from them. // to collect lookups from them.
if (!plan->all_axes_pinned) 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, plan->user_axes_location.is_empty () ? nullptr: feature_record_cond_idx_map,
lookup_indices); lookup_indices);
#endif #endif

@ -0,0 +1,11 @@
FONTS:
AnekBangla-question-subset.ttf
PROFILES:
default.txt
SUBSETS:
*
INSTANCES:
wdth=112.5

@ -77,6 +77,7 @@ if get_option('experimental_api')
'feature_variations_partial_instance', 'feature_variations_partial_instance',
'gdef_partial_instance', 'gdef_partial_instance',
'value_format_partial_instance', 'value_format_partial_instance',
'feature_variation_instance_collect_lookups',
] ]
endif endif

Loading…
Cancel
Save