diff --git a/src/hb-aat-layout-feat-table.hh b/src/hb-aat-layout-feat-table.hh index 8de7873e4..14f91bf9a 100644 --- a/src/hb-aat-layout-feat-table.hh +++ b/src/hb-aat-layout-feat-table.hh @@ -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); } diff --git a/src/hb-aat-map.cc b/src/hb-aat-map.cc index bc879359a..fc1dcbd2d 100644 --- a/src/hb-aat-map.cc +++ b/src/hb-aat-map.cc @@ -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 (); + 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; feature_info_t *info = features.push(); info->type = mapping->aatFeatureType;