答案 0 :(得分:2)
我已经弄清楚了。
OSF是某些字体中包含的可选功能,因此我们需要使用
激活此功能UIFontDescriptor *fontDescriptor = [UIFontDescriptor fontDescriptorWithFontAttributes:@{
UIFontDescriptorNameAttribute : @"MyriadPro-Light",
UIFontDescriptorFeatureSettingsAttribute : @[osfFontFeature]
}];
osfFontFeature是
NSDictionary *osfFontFeature = @{
UIFontFeatureTypeIdentifierKey : @(21),
UIFontFeatureSelectorIdentifierKey : @(0)
};
可在此处获取要素类型和选择标识符键: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html#Type21
最后,我们使用
创建字体[UIFont fontWithDescriptor:fontDescriptor size:17.0]