If an AAT feature type is not exposed in the 'feat' table, we assume it is not intended to be user-controllable and so we should not map any OT feature tag requests to it. Fixes #2285.
@ -129,6 +129,9 @@ struct FeatureName
hb_ot_name_id_t get_feature_name_id () const { return nameIndex; }
/* A FeatureName with no settings is meaningless */
bool has_data () const { return nSettings > 0; }
bool sanitize (hb_sanitize_context_t *c, const void *base) const
{
TRACE_SANITIZE (this);
@ -172,6 +175,9 @@ struct feat
return featureNameCount;
}
bool exposes_feature (hb_aat_layout_feature_type_t feature_type) const
{ return get_feature (feature_type).has_data (); }
const FeatureName& get_feature (hb_aat_layout_feature_type_t feature_type) const
{ return namesZ.bsearch (featureNameCount, feature_type); }
@ -33,13 +33,19 @@
#include "hb-aat-map.hh"
#include "hb-aat-layout.hh"
#include "hb-aat-layout-feat-table.hh"
void hb_aat_map_builder_t::add_feature (hb_tag_t tag,
unsigned int value)
hb_blob_t *feat_blob = face->table.feat.get_blob ();
const AAT::feat& feat = *feat_blob->as<AAT::feat> ();
if (!feat.has_data ()) return;
if (tag == HB_TAG ('a','a','l','t'))
if (!feat.exposes_feature (HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_ALTERNATIVES)) return;
feature_info_t *info = features.push();
info->type = HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_ALTERNATIVES;
info->setting = (hb_aat_layout_feature_selector_t) value;
@ -48,6 +54,7 @@ void hb_aat_map_builder_t::add_feature (hb_tag_t tag,
const hb_aat_feature_mapping_t *mapping = hb_aat_layout_find_feature_mapping (tag);
if (!mapping) return;
if (!feat.exposes_feature (mapping->aatFeatureType)) return;
info->type = mapping->aatFeatureType;