textswiftuicustom-font

How can i make my text bold with custom font in SwiftUI Text?


How can i make my text bold with custom font in SwiftUI Text:

Text("Any text").font(.custom("PFDinTextCompPro-Regular", size: 10))

.fontWeight(.heavy) and .custom("PFDinTextCompPro-Regular", size: 10).bold() not working!

But this works on Android with the same .ttf file!


Solution

  • I am assuming you have added the custom font in your .plist file. Similarly you should have the "PDFinTextCompPro-heavy/bold" ttf in the .plist . If you haven't, check this link out.

    Link to Custom font config

    Edit : I agree with Hieu Dinh, you should have separate Bold, Heavy, Medium, Light and Regular .ttf files, if you add them in the .plist it should work .