I want to use the New York Extra Large
, New York Small
etc fonts in SwiftUI, as they have a specific optical size.
I know I can use New York as a system font via .serif, so how can I access Extra Large etc as a system font?
RN I’m using
Text("Text")
.font(.system(size: 64, weight: .bold, design: .serif))
But I can’t set optical size here/use ExtraLarge presets
2
Answers
If you wish to use a predefined size, use
Font
‘ssystem(_:design:weight:)
initializer:This will draw the text in New York font with a "large title" size and bold weight. The first parameter is the font size, the next is the design, and the third is the weight.
If you wish to use a custom size, use the
system(size:weight:design:)
initializer:This will draw in New York font with size 17.
These are the default fonts provided: http://iosfonts.com
Custom fonts need to be added separately in Xcode.