[coretext] Prepare AAT feature mapping to be moved

This commit is contained in:
Behdad Esfahbod 2018-10-13 17:03:32 -04:00
parent de6e414c56
commit cb05774913
1 changed files with 22 additions and 17 deletions

View File

@ -515,12 +515,21 @@ struct range_record_t {
#define kUpperCaseType 38 #define kUpperCaseType 38
/* Table data courtesy of Apple. */ /* Table data courtesy of Apple. */
static const struct feature_mapping_t static const struct hb_aat_feature_mapping_t
{ {
hb_tag_t otFeatureTag; hb_tag_t otFeatureTag;
uint16_t aatFeatureType; uint16_t aatFeatureType;
uint16_t selectorToEnable; uint16_t selectorToEnable;
uint16_t selectorToDisable; uint16_t selectorToDisable;
static inline int cmp (const void *key_, const void *entry_)
{
hb_tag_t key = * (unsigned int *) key_;
const hb_aat_feature_mapping_t * entry = (const hb_aat_feature_mapping_t *) entry_;
return key < entry->otFeatureTag ? -1 :
key > entry->otFeatureTag ? 1 :
0;
}
} feature_mappings[] = } feature_mappings[] =
{ {
{ 'c2pc', kUpperCaseType, kUpperCasePetiteCapsSelector, kDefaultUpperCaseSelector }, { 'c2pc', kUpperCaseType, kUpperCasePetiteCapsSelector, kDefaultUpperCaseSelector },
@ -600,14 +609,14 @@ static const struct feature_mapping_t
{ 'zero', kTypographicExtrasType, kSlashedZeroOnSelector, kSlashedZeroOffSelector }, { 'zero', kTypographicExtrasType, kSlashedZeroOnSelector, kSlashedZeroOffSelector },
}; };
static int HB_INTERNAL const hb_aat_feature_mapping_t *
_hb_feature_mapping_cmp (const void *key_, const void *entry_) hb_aat_layout_find_feature_mapping (hb_tag_t tag)
{ {
hb_tag_t key = * (unsigned int *) key_; return bsearch (&tag,
const feature_mapping_t * entry = (const feature_mapping_t *) entry_; feature_mappings,
return key < entry->otFeatureTag ? -1 : ARRAY_LENGTH (feature_mappings),
key > entry->otFeatureTag ? 1 : sizeof (feature_mappings[0]),
0; hb_aat_feature_mapping_t::cmp);
} }
hb_bool_t hb_bool_t
@ -655,11 +664,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
hb_auto_t<hb_vector_t<feature_event_t> > feature_events; hb_auto_t<hb_vector_t<feature_event_t> > feature_events;
for (unsigned int i = 0; i < num_features; i++) for (unsigned int i = 0; i < num_features; i++)
{ {
const feature_mapping_t * mapping = (const feature_mapping_t *) bsearch (&features[i].tag, const hb_aat_feature_mapping_t * mapping = hb_aat_layout_find_feature_mapping (features[i].tag);
feature_mappings,
ARRAY_LENGTH (feature_mappings),
sizeof (feature_mappings[0]),
_hb_feature_mapping_cmp);
if (!mapping) if (!mapping)
continue; continue;