[AAT] Don't map OT tags to AAT feature types that are not exposed.

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.
This commit is contained in:
Jonathan Kew authored and Ebrahim Byagowi committed 2020-04-02 23:58:32 +04:30
1 parent e0c3979af1
commit b1c0b9da2f
2 files changed
+13

No files matched your search

+6
View File
@@ -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); }
+7
View File
@@ -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;
feature_info_t *info = features.push();
info->type = mapping->aatFeatureType;