我想通过启用它支持的OpenType功能来修改旧金山字体,例如one storey a或opened four and six。此设置应仅适用于正文文体样式。在iOS系统字体中启用正文文本样式的排版功能
文本样式是设置在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 [打开四和六]的示例(https://i.stack.imgur.com/ogG7Z.gif)。 [一层]的示例(https://en.wikipedia.org/wiki/A#/media/File:LowercaseA.svg)。 – Boletrone