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))
You can even rename the file as you wish but you will always use "Bricolage Grotesque" to reference the font.
Top comments (0)