ios - 无法访问系统小型大写字体
问题描述
我正在使用以下方法获取系统小型大写字体:
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 版本的任何其他方式。我该怎么做呢?
解决方案
推荐阅读
- css - CSS Responsive 对我的网站来说很奇怪,宽度自动
- docker - 具有 'exec' 权限的 Docker --mount type=tmpfs
- javascript - 更改猫头鹰转马时间
- python - 如何让 Python Infinite while / else 语句中断?
- ruby-on-rails - 无法在 Bigsur 上安装 mysql2 Gem
- selenium-chromedriver - 如何为具有相同名称的多个输入设置值?
- c# - 使用图像而不是文本的 Visual Studio 注释
- javascript - 在多个值的对象数组中搜索
- php - Symfony 表单类型从另一个实体添加查询构建器
- javascript - 两个 Angular 应用程序之间的通信