skip to Main Content

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


  1. If you wish to use a predefined size, use Font‘s system(_:design:weight:) initializer:

    Text("Hello")
        .font(.system(.largeTitle, design: .serif, weight: .bold))
    

    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:

    Text("Hello")
        .font(.system(size: 17, weight: .bold, design: .serif))
    

    This will draw in New York font with size 17.

    Login or Signup to reply.
  2. These are the default fonts provided: http://iosfonts.com

    import SwiftUI
    
    struct TestView: View {
        var body: some View {
            Text("Text")
                .font(Font.custom("Academy Engraved LET", size: 64))
        }
    }
    

    Custom fonts need to be added separately in Xcode.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search