The regular font seems to work, but the all the others (italic, bold, etc.) don't seem to show up on the simulator. Only the storyboard. I added everything to Info.plist and included the files in a custom folder. i don't know what i could have missed! Why is it so hard to add a custom font to swift?
Asked
Active
Viewed 582 times
-5
-
Have you tried this ?? -> https://stackoverflow.com/questions/16636196/opensans-font-not-working-in-ios-simulator – dahiya_boy Mar 04 '19 at 04:42
-
This example uses objective-C. I'm using swift and haven't put anything in code. I simply added the fonts to info.plist with my folder of custom fonts. For some reason only regular works. I'm perplexed as to why. NOTE: i'm using the inspector only, no code – Bieksa Mar 04 '19 at 04:44
-
Check **Targets** > **Build Phases** > **Copy Resources** . There must be your fonts available. I checked this font in dummy , its working fine in simulator. – dahiya_boy Mar 04 '19 at 04:55
-
Hmm.. it only works on the storyboard, NOT on the simulator. i have no idea why – Bieksa Mar 04 '19 at 04:59
-
Dahiya, I have the folder containing all the fonts here – Bieksa Mar 04 '19 at 05:01
-
@Bieksa make sure your fonts folder added the file by selecting "Create groups" instead of "Create folder references" – Govind Kumawat Mar 04 '19 at 05:09
-
https://stackoverflow.com/a/36071063/8918347 – Govind Kumawat Mar 04 '19 at 05:09
-
@dahiya_boy I put the individual font .ttl files in target and it seemed to work. – Bieksa Mar 04 '19 at 05:15
-
@GovindKumawat that didn't seem to work for me! The only way I could get it to work is to add each .ttl individually in targets. I wonder if there's a simpler way to do this! – Bieksa Mar 04 '19 at 05:15
1 Answers
2
Use this function in appDelegate to track font names which you use.
func printFonts() {
let fontFamilyNames = UIFont.familyNames
for familyName in fontFamilyNames {
print("------------------------------")
print("Font Family Name = [\(familyName)]")
let names = UIFont.fontNames(forFamilyName: familyName)
print("Font Names = [\(names)]")
}
}
Call From didFinishLaunching
in appDelegate

Nilesh R Patel
- 697
- 7
- 17