Reputation: 16281
I have followed a number of tutorials in adding a custom font to my SwiftUI package. I have take the following steps:
Font Awesome 5 Free Solid-900.otf
to my project.Fonts provided by application
array in Info.plist
I tried the following:
Text(Text("\u{f071} Danger Will Robinson").font(.custom("Font Awesome 5 Free Regular", size: 20))
which is supposed to give me an alert icon, but all I get is a question mark.
Is there a trick to using Font Awesome in this way?
I know there are a few packages available, but I’m trying to learn more about the process itself, and I can’t see that it should be too hard.
Upvotes: 2
Views: 1617
Reputation: 16281
OK, I worked it out.
Info.plist
key is: Application fonts resource path
, not as above.One method is to install the font, and then check FontBook. The PostScript name is the name I need.
The other is to run the following code:
let fontManager = NSFontManager.shared
let fonts = fontManager.availableFonts
for name in fonts {
print(name)
}
That’s what happens when all the tutorials are for iOS, not MacOS.
Upvotes: 4