无法访问系统 Small Caps 字体

时间:2021-04-20 07:02:05

标签: ios swift xcode uikit uifont

我使用以下方法获取系统小型大写字体:

    let systemFont = UIFont.systemFont(ofSize: 16.0, weight: UIFont.Weight.regular)
    
    let smallCapsDesc = systemFont.fontDescriptor.addingAttributes([
        UIFontDescriptor.AttributeName.featureSettings: [
            [
                UIFontDescriptor.FeatureKey.featureIdentifier: kLowerCaseType,
                UIFontDescriptor.FeatureKey.typeIdentifier: kUpperCaseSmallCapsSelector
            ]
        ]
    ])
    let smallCapsFont = UIFont(descriptor: smallCapsDesc, size: systemFont.pointSize)
    let smallCapsAttrbs: [NSAttributedString.Key : Any] = [NSAttributedString.Key.font : smallCapsFont]

    text.setAttributes(smallCapsAttrbs, range: NSRange(location: start, length: length))

并且我收到此错误。

<块引用>

CoreText 注意:客户端请求的名称“.SFUI-Regular”,它会得到 TimesNewRomanPSMT 而不是预期的字体。所有系统UI字体 访问应通过适当的 API 进行,例如 CTFontCreateUIFontForLanguage() 或 +[UIFont systemFontOfSize:].

我不确定是否有其他方法可以获取 San Francisco 字体的 smallCaps 版本。我该怎么做?

0 个答案:

没有答案
相关问题