From f0c78e028261a7823194cccc7be241aa9ddbac25 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Thu, 25 Mar 2021 12:57:12 -0700 Subject: [PATCH] [subset] don't drop features referenced in a feature variation substitution. --- src/hb-ot-layout-common.hh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 45aed92bb..a049cecc4 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -1108,7 +1108,7 @@ struct Feature auto *out = c->serializer->start_embed (*this); if (unlikely (!out || !c->serializer->extend_min (out))) return_trace (false); - bool subset_featureParams = out->featureParams.serialize_subset (c, featureParams, this, tag); + out->featureParams.serialize_subset (c, featureParams, this, tag); auto it = + hb_iter (lookupIndex) @@ -1117,8 +1117,9 @@ struct Feature ; out->lookupIndex.serialize (c->serializer, l, it); - return_trace (bool (it) || subset_featureParams - || (tag && *tag == HB_TAG ('p', 'r', 'e', 'f'))); + // The decision to keep or drop this feature is already made before we get here + // so always retain it. + return_trace (true); } bool sanitize (hb_sanitize_context_t *c, @@ -3001,6 +3002,12 @@ struct FeatureTableSubstitutionRecord bool subset (hb_subset_layout_context_t *c, const void *base) const { TRACE_SUBSET (this); + if (!c->feature_index_map->has (featureIndex)) { + // Feature that is being substituted is not being retained, so we don't + // need this. + return_trace (false); + } + auto *out = c->subset_context->serializer->embed (this); if (unlikely (!out)) return_trace (false);