[coretext] Use kCTFontOpenTypeFeatureTag
Instead of trying to map OpenType features to AAT feature selectors which only works for a small subset of OpenType features, use the simpler kCTFontOpenTypeFeatureTag with OpenType feature tags directly. With this change, features like cvXX can be enabled in coretext shaper, while they were previously ignored due to missing mapping. This seems to work even with AAT fonts that don’t have OpenType layout tables, which suggests that CoreText is doing the mapping itself in this case. kCTFontOpenTypeFeatureTag seems to have been introduced in macOS 10.10 and iOS 8.0, though, so its use is conditional on version check for now. Not sure how to check iOS version, so I left this out.
This commit is contained in:
parent
b28c282585
commit
68c1798a67
|
@ -475,13 +475,19 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
|
|||
hb_vector_t<feature_event_t> feature_events;
|
||||
for (unsigned int i = 0; i < num_features; i++)
|
||||
{
|
||||
active_feature_t feature;
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1010
|
||||
const hb_aat_feature_mapping_t * mapping = hb_aat_layout_find_feature_mapping (features[i].tag);
|
||||
if (!mapping)
|
||||
continue;
|
||||
|
||||
active_feature_t feature;
|
||||
feature.rec.feature = mapping->aatFeatureType;
|
||||
feature.rec.setting = features[i].value ? mapping->selectorToEnable : mapping->selectorToDisable;
|
||||
#else
|
||||
feature.rec.feature = features[i].tag;
|
||||
feature.rec.setting = features[i].value;
|
||||
#endif
|
||||
feature.order = i;
|
||||
|
||||
feature_event_t *event;
|
||||
|
@ -530,6 +536,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
|
|||
/* active_features.qsort (); */
|
||||
for (unsigned int j = 0; j < active_features.length; j++)
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1010
|
||||
CFStringRef keys[] = {
|
||||
kCTFontFeatureTypeIdentifierKey,
|
||||
kCTFontFeatureSelectorIdentifierKey
|
||||
|
@ -538,6 +545,17 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
|
|||
CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &active_features[j].rec.feature),
|
||||
CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &active_features[j].rec.setting)
|
||||
};
|
||||
#else
|
||||
char tag[5] = {HB_UNTAG (active_features[j].rec.feature)};
|
||||
CFTypeRef keys[] = {
|
||||
kCTFontOpenTypeFeatureTag,
|
||||
kCTFontOpenTypeFeatureValue
|
||||
};
|
||||
CFTypeRef values[] = {
|
||||
CFStringCreateWithCString (kCFAllocatorDefault, tag, kCFStringEncodingASCII),
|
||||
CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &active_features[j].rec.setting)
|
||||
};
|
||||
#endif
|
||||
static_assert ((ARRAY_LENGTH_CONST (keys) == ARRAY_LENGTH_CONST (values)), "");
|
||||
CFDictionaryRef dict = CFDictionaryCreate (kCFAllocatorDefault,
|
||||
(const void **) keys,
|
||||
|
|
Loading…
Reference in New Issue