I’m trying to add a custom font to my app but it doesn’t appear when the app is running:
- Added the files to the project
- Checked the font is within the Target Membership
- Added the fonts to the app plist under the "Fonts provided by application":
- Checked the fonts are within the Target/ Build Phases/ Copy Bundle Resources:
- Installed the fonts in the Font Book
After that, when I run the app:
for (NSString* family in [UIFont familyNames])
{
NSLog(@"FONT FAMILY: %@", family);
for (NSString* name in [UIFont fontNamesForFamilyName: family])
{
NSLog(@"FONT: %@", name);
}
}
All fonts except the JetBrains ones are available. What am I missing?
2
Answers
Found the answer.
Changed the "Fonts provided by application" key in the .plist file with "UIAppFonts" and the font started to work
This code
[UIFont familyNames]
searches in the system fonts , while the font you added is a custom one which for sure doesn’t exist inside them ,you can access it throughUIFont
‘sfontWithName
initializer