ios - 如何在 ios 中启用 osf(旧式图形)?

标签 ios objective-c xcode

所以我的问题是我的字体女巫支持 osf (旧式图形)但我不知道如何使用 UIFont 启用它?

最佳答案

我想通了。

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]

关于ios - 如何在 ios 中启用 osf(旧式图形)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25990587/

相关文章:

swift - 如何让 UILabel 在 Today 扩展中显示多行?

ios - 如何在 iOS 中以编程方式禁用/启用 sleep 模式?

iOS Storyboard传递数据 navigationViewController

ios - Xcode 申请提交失败

ios - 带有文本的 xcode 不可见按钮

objective-c - NSWindow 如何设置和获取标识符

升级到 OS 4.0 的 XCode 3.2.3 Beta4 后,iPhone Simulator 3.x 未列出

ios - 向下滑动以关闭时 ASWebAuthenticationSessionError.canceledLogin 不会触发

ios - 自动布局无法同时满足约束

iOS 15 导航栏和表格 View 之间的差距