Thursday, 24 September 2020

Custom font not showing up in SwiftUI

I've followed all the steps in Apple's tutorial to add custom fonts:

I've added the font files under a folder called fonts:

enter image description here

I've registered the fonts by adding them to Info.plist:

enter image description here

However Xcode cannot use them/find them:

Button(action: {}){
                Text("View profile")
                    .font(Font.custom("seravekBold.tff", size: 20.0))

I've also tried testing this method:

for family in UIFont.familyNames.sorted() {
    let names = UIFont.fontNames(forFamilyName: family)
    print("Family: \(family) Font names: \(names)")
}

in my AppDelegate to print out all the UI fonts and the fonts I added (seravek) do not show up.

Any idea what the problem is?



from Custom font not showing up in SwiftUI

No comments:

Post a Comment