[subset] only keep features reachable from script in the final subset.
Matches fontTools behaviour.
This commit is contained in:
parent
e583505334
commit
718bf5aab3
|
@ -3380,20 +3380,31 @@ struct GSUBGPOS
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void closure_features (const hb_map_t *lookup_indexes, /* IN */
|
void prune_features (const hb_map_t *lookup_indices, /* IN */
|
||||||
hb_set_t *feature_indexes /* OUT */) const
|
hb_set_t *feature_indices /* IN/OUT */) const
|
||||||
{
|
{
|
||||||
unsigned int feature_count = hb_min (get_feature_count (), (unsigned) HB_MAX_FEATURES);
|
#ifndef HB_NO_VAR
|
||||||
for (unsigned i = 0; i < feature_count; i++)
|
// This is the set of feature indices which have alternate versions defined
|
||||||
|
// if the FeatureVariation's table and the alternate version(s) intersect the
|
||||||
|
// set of lookup indices.
|
||||||
|
hb_set_t alternate_feature_indices;
|
||||||
|
if (version.to_int () >= 0x00010001u)
|
||||||
|
(this+featureVars).closure_features (lookup_indices, &alternate_feature_indices);
|
||||||
|
if (alternate_feature_indices.in_error()) {
|
||||||
|
feature_indices->successful = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (unsigned i : feature_indices->iter())
|
||||||
{
|
{
|
||||||
const Feature& f = get_feature (i);
|
const Feature& f = get_feature (i);
|
||||||
if ((!f.featureParams.is_null ()) || f.intersects_lookup_indexes (lookup_indexes))
|
|
||||||
feature_indexes->add (i);
|
if (f.featureParams.is_null ()
|
||||||
|
&& !f.intersects_lookup_indexes (lookup_indices)
|
||||||
|
&& !alternate_feature_indices.has (i))
|
||||||
|
feature_indices->del (i);
|
||||||
}
|
}
|
||||||
#ifndef HB_NO_VAR
|
|
||||||
if (version.to_int () >= 0x00010001u)
|
|
||||||
(this+featureVars).closure_features (lookup_indexes, feature_indexes);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int get_size () const
|
unsigned int get_size () const
|
||||||
|
|
|
@ -88,10 +88,17 @@ _gsub_closure_glyphs_lookups_features (hb_face_t *face,
|
||||||
&lookup_indices);
|
&lookup_indices);
|
||||||
_remap_indexes (&lookup_indices, gsub_lookups);
|
_remap_indexes (&lookup_indices, gsub_lookups);
|
||||||
|
|
||||||
//closure features
|
// Collect and prune features
|
||||||
hb_set_t feature_indices;
|
hb_set_t feature_indices;
|
||||||
gsub->closure_features (gsub_lookups, &feature_indices);
|
hb_ot_layout_collect_features (face,
|
||||||
|
HB_OT_TAG_GSUB,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
&feature_indices);
|
||||||
|
gsub->prune_features (gsub_lookups, &feature_indices);
|
||||||
_remap_indexes (&feature_indices, gsub_features);
|
_remap_indexes (&feature_indices, gsub_features);
|
||||||
|
|
||||||
gsub.destroy ();
|
gsub.destroy ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,9 +121,15 @@ _gpos_closure_lookups_features (hb_face_t *face,
|
||||||
&lookup_indices);
|
&lookup_indices);
|
||||||
_remap_indexes (&lookup_indices, gpos_lookups);
|
_remap_indexes (&lookup_indices, gpos_lookups);
|
||||||
|
|
||||||
//closure features
|
// Collect and prune features
|
||||||
hb_set_t feature_indices;
|
hb_set_t feature_indices;
|
||||||
gpos->closure_features (gpos_lookups, &feature_indices);
|
hb_ot_layout_collect_features (face,
|
||||||
|
HB_OT_TAG_GPOS,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
&feature_indices);
|
||||||
|
gpos->prune_features (gpos_lookups, &feature_indices);
|
||||||
_remap_indexes (&feature_indices, gpos_features);
|
_remap_indexes (&feature_indices, gpos_features);
|
||||||
gpos.destroy ();
|
gpos.destroy ();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue