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 growth stunted Image

If you are wasting time trying to track down the cause of a crash, it’s time for a better solution. Get your crash rates to zero (or close to zero as possible) with less time and effort.

Try Sentry for more visibility into crashes, better workflow tools, and customizable alerts and reporting.

Switch Tools 🔁

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more