-2

I want to add custom fonts to my swift ui game. Does anyone know how to do that? I tried watching a youtube video but i couldn’t find any good ones.

LlamaDev
  • 13
  • 3
  • 1
    Does this answer your question? [SwiftUI won't display custom font](https://stackoverflow.com/questions/58864731/swiftui-wont-display-custom-font) – Andrew Nov 20 '20 at 07:23

1 Answers1

1

Add custom font to your project and register it in .plist https://developer.apple.com/documentation/uikit/text_display_and_fonts/adding_a_custom_font_to_your_app

Then define

extension Font {
    struct Event {
        let name = Font.custom("GillSans-UltraBold", size: 14)
        let location = Font.custom("GillSans-SemiBold", size: 10)
        let date = Font.custom("GillSans-UltraBold", size: 16)
        let price = Font.custom("GillSans-SemiBoldItalic", size: 12)
    }
    static let event = Event()
}

Example usage:

Text("iPhone 12 Pro Super Max").font(Font.event.name)
Quang Hà
  • 4,613
  • 3
  • 24
  • 40