A UIFont
可以很容易地通过字体描述符进行设置,例如,在SwiftUI中如何实现同样的功能?
let settings: [UIFontDescriptor.FeatureKey: Int] = [
.featureIdentifier: kStylisticAlternativesType,
.typeIdentifier: 2]
let descriptor = someBaseFont.fontDescriptor.addingAttributes([.featureSettings: [settings]])
let newFont = UIFont(descriptor: descriptor, size: size)
(如何)可以在SwiftUI中实现同样的功能?
暂时没有直接的方法,但这里有一个解决方案。
// .. your above code
let newFont = UIFont(descriptor: descriptor, size: size)
let myFont = Font(newFont as CTFont) // << here !!