7

I have fonts defined with custom parameters:

public var suiFont: Font {
    .custom(name, size: size)
}

And then I need to use them to create UIKit's UIFont. How can I get parameters from Font struct? I found solution for standard fonts:

UIFont.preferredFont(forTextStyle: .body).pointSize
UIFont.preferredFont(forTextStyle: .body).fontName
UIFont.preferredFont(forTextStyle: .body).fontDescriptor

but it's not suitable in my case because of my fonts was created with custom arguments. For example Font.custom("SFUI", size: 25) returns size 17.

Are there other ways to get font parameters from SwiftUI Font? How standard SwiftUI elements do it with wrapped UIKit elements?

General Failure
  • 2,421
  • 4
  • 23
  • 49

0 Answers0