3

A UIFont can easily be setup via the font descriptor, e.g.

let settings: [UIFontDescriptor.FeatureKey: Int] = [            
   .featureIdentifier: kStylisticAlternativesType,
   .typeIdentifier: 2]

let descriptor = someBaseFont.fontDescriptor.addingAttributes([.featureSettings: [settings]])
let newFont = UIFont(descriptor: descriptor, size: size)

(How) is it possible to achieve the same in SwiftUI?

1 Answer 1

4

No direct way for now, but here is a solution:

// .. your above code
let newFont = UIFont(descriptor: descriptor, size: size)
let myFont = Font(newFont as CTFont)                       // << here !!
Sign up to request clarification or add additional context in comments.

2 Comments

Mh not what I was hoping for but it does work. Thank you
@benrudhart Usual Apple

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.