[instance] drop and don't collect lookups from feature variations when fully instancing.

This previously incorrectly collected lookups that could be reached via feature variations that are dropped and not activated by the current instance position.
pull/4034/head
Garret Rieger 2 years ago committed by Behdad Esfahbod
parent d250148db0
commit ea1ee0d4b6
  1. 23
      src/hb-ot-layout-gsubgpos.hh
  2. 12
      src/hb-subset-plan.cc
  3. BIN
      test/subset/data/expected/instance_feature_variations/MPLUS1-Variable.default.30DD.wght=100.ttf
  4. BIN
      test/subset/data/expected/instance_feature_variations/MPLUS1-Variable.default.30DD.wght=400.ttf
  5. BIN
      test/subset/data/expected/instance_feature_variations/MPLUS1-Variable.default.retain-all-codepoint.wght=400.ttf
  6. BIN
      test/subset/data/expected/instance_feature_variations/MPLUS1-Variable.notdef-outline.retain-all-codepoint.wght=400.ttf
  7. BIN
      test/subset/data/expected/layout.gdef-varstore/AdobeVFPrototype.layout-test-retain-gids.41,42,43,57.otf
  8. BIN
      test/subset/data/expected/layout.gdef-varstore/AdobeVFPrototype.layout-test-retain-gids.41,42,43.otf
  9. BIN
      test/subset/data/expected/layout.gdef-varstore/AdobeVFPrototype.layout-test-retain-gids.41,42.otf
  10. BIN
      test/subset/data/expected/layout.gdef-varstore/AdobeVFPrototype.layout-test-retain-gids.41,56,57.otf
  11. BIN
      test/subset/data/expected/layout.gdef-varstore/AdobeVFPrototype.layout-test-retain-gids.41.otf
  12. BIN
      test/subset/data/expected/layout.gdef-varstore/AdobeVFPrototype.layout-test-retain-gids.42,57.otf
  13. BIN
      test/subset/data/expected/layout.gdef-varstore/AdobeVFPrototype.layout-test.41,42,43,57.otf
  14. BIN
      test/subset/data/expected/layout.gdef-varstore/AdobeVFPrototype.layout-test.41,42,43.otf
  15. BIN
      test/subset/data/expected/layout.gdef-varstore/AdobeVFPrototype.layout-test.41,42.otf
  16. BIN
      test/subset/data/expected/layout.gdef-varstore/AdobeVFPrototype.layout-test.41,56,57.otf
  17. BIN
      test/subset/data/expected/layout.gdef-varstore/AdobeVFPrototype.layout-test.41.otf
  18. BIN
      test/subset/data/expected/layout.gdef-varstore/AdobeVFPrototype.layout-test.42,57.otf
  19. BIN
      test/subset/data/expected/variable/Fraunces.default.61.ttf
  20. 4
      test/subset/data/tests/instance_feature_variations.tests

@ -4142,8 +4142,11 @@ struct GSUBGPOSVersion1_2
bool subset (hb_subset_layout_context_t *c) const
{
TRACE_SUBSET (this);
auto *out = c->subset_context->serializer->embed (*this);
if (unlikely (!out)) return_trace (false);
auto *out = c->subset_context->serializer->start_embed (this);
if (unlikely (!c->subset_context->serializer->extend_min (out))) return_trace (false);
out->version = version;
typedef LookupOffsetList<TLookup, typename Types::HBUINT> TLookupList;
reinterpret_cast<typename Types::template OffsetTo<TLookupList> &> (out->lookupList)
@ -4166,9 +4169,23 @@ struct GSUBGPOSVersion1_2
#ifndef HB_NO_VAR
if (version.to_int () >= 0x00010001u)
{
bool ret = out->featureVars.serialize_subset (c->subset_context, featureVars, this, c);
auto snapshot = c->subset_context->serializer->snapshot ();
if (!c->subset_context->serializer->extend_min (&out->featureVars))
return_trace (false);
// TODO(qxliu76): the current implementation doesn't correctly handle feature variations
// that are dropped by instancing when the associated conditions don't trigger.
// Since partial instancing isn't yet supported this isn't an issue yet but will
// need to be fixed for partial instancing.
// if all axes are pinned all feature vars are dropped.
bool ret = !c->subset_context->plan->all_axes_pinned
&& out->featureVars.serialize_subset (c->subset_context, featureVars, this, c);
if (!ret && version.major == 1)
{
c->subset_context->serializer->revert (snapshot);
out->version.major = 1;
out->version.minor = 0;
}

@ -188,7 +188,17 @@ static void _collect_layout_indices (hb_subset_plan_t *plan,
f->add_lookup_indexes_to (lookup_indices);
}
table.feature_variation_collect_lookups (feature_indices, feature_substitutes_map, lookup_indices);
// 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)
{
// TODO(qxliu76): this collection doesn't work correctly for feature variations that are dropped
// but not applied. The collection will collect and retain the lookup indices
// associated with those dropped but not activated rules. Since partial instancing
// isn't yet supported this isn't an issue yet but will need to be fixed for
// partial instancing.
table.feature_variation_collect_lookups (feature_indices, feature_substitutes_map, lookup_indices);
}
}

@ -3,10 +3,10 @@ MPLUS1-Variable.ttf
PROFILES:
default.txt
notdef-outline.txt
SUBSETS:
*
INSTANCES:
wght=100
wght=400

Loading…
Cancel
Save