【发布时间】:2017-09-17 22:27:12
【问题描述】:
我想通过启用它支持的 OpenType 功能来修改 San Francisco 字体,例如 one storey a 或 opened four and six。此设置应仅适用于正文样式。
文本样式在 Storyboard 中设置属性检查器,不在代码中。
由于某种原因,下面的代码不起作用:
let bodyFontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body)
// This isn’t working either: let bodyFontDescriptor = UIFont.preferredFont(forTextStyle: .body).fontDescriptor
let oneStoreyAFontDescriptor = bodyFontDescriptor.addingAttributes(
[
UIFontDescriptorFeatureSettingsAttribute:
[
[
UIFontFeatureTypeIdentifierKey: kStylisticAlternativesType,
UIFontFeatureSelectorIdentifierKey: kStylisticAltSevenOnSelector
]
]
]
)
textView.font = UIFont(descriptor: oneStoreyAFontDescriptor, size: 0.0)
我做错了什么?一般来说,这是正确的方法吗?
【问题讨论】:
-
无法理解一层a或开四六层。
-
@dahiya_boy open four and six 的示例。 one storey a 的示例。
标签: ios swift fonts uifont typography