Reputation: 147
I had a SwiftUI project that I essentially messed up pretty bad and had to make a new project and transfer all the files over. It's working as intended except for my custom fonts aren't working and the default font is taking over. Here is what I did:
And yeah, still not working. Any insight as to what I could be overlooking? Because it was working completely as intended before I had to create the new project, and all other elements are working as intended.
Upvotes: 1
Views: 2175
Reputation: 1172
If you are struggling with this in 2022 and using SwiftUI where there seems to be no info.plist in sight, then in addition to adding the Fonts capability in Target Signing and Capabilities, then dragging the file into your project and don't forget to check Add to Targets, and finally add your InsertFontFileName.ttf to "Fonts provided by application" which is now in your Info tab on the Target as seen in the image below. Also, call me crazy but before you drag the font in remove any special characters. In addition, don't be fooled by the auto-generated info.plist, add your new fonts via the image below, it'll auto-populate to that other plist. Maybe some of my steps are superstitious, but I spent enough time futzing around with fonts that I'm done thinking about it and I'll just follow my formula... and if that font doesn't work, it wasn't meant to be and I'll move onto the next font!
After that
.font(Font.custom("InsertFontFileName", size: 32, relativeTo: .title))
Upvotes: 5
Reputation: 1238
Although it looks like you have already done this, just go through the following checklist once:
var FontRegular : Font = Font.custom("Poppins-Regular", size: 16)
var FontBold : Font = Font.custom("Poppins-Bold", size: 16)
...
Text("Sample Text")
.font(FontRegular)
Upvotes: 2