DEV Community

Mateus Rodrigues
Mateus Rodrigues

Posted on • Edited on

1

Note on SwiftUI Custom Font

There's a very important information in Applying custom fonts to text that may go unnoticed:

When retrieving the font with custom(_:size:), match the name of the font with the font’s PostScript name. You can find the postscript name of a font by opening it with the Font Book app and selecting the Font Info tab.

This means that the font name is not necessarily the same as the font filename.

Consider, for example, the Bricolage Grotesque font. If you download it, you will have a file named BricolageGrotesque-VariableFont_opsz,wdth,wght.ttf, but the name that you will use in the code is actually Bricolage Grotesque.

Text("Hello, world!")
    .font(Font.custom("Bricolage Grotesque", size: 18))
Enter fullscreen mode Exit fullscreen mode

You can even rename the file as you wish but you will always use "Bricolage Grotesque" to reference the font.

Sentry mobile image

App store rankings love fast apps - mobile vitals can help you get there

Slow startup times, UI hangs, and frozen frames frustrate users—but they’re also fixable. Mobile Vitals help you measure and understand these performance issues so you can optimize your app’s speed and responsiveness. Learn how to use them to reduce friction and improve user experience.

Read full post →

Top comments (0)

Sentry mobile image

Mobile Vitals: A first step to Faster Apps

Slow startup times, UI hangs, and frozen frames frustrate users—but they’re also fixable. Mobile Vitals help you measure and understand these performance issues so you can optimize your app’s speed and responsiveness. Learn how to use them to reduce friction and improve user experience.

Read the guide →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay