Reputation: 9376
I've never had this problem before. But I can't get any font to show up besides the system font. I wanted to use helvetica, but that wasn't working, I have tried setting my UILabel's to Farah just to see if it would work and it doesn't. However, if I run in the simulator (with iOS7) then it seems to work fine. I've tried setting fonts on the storyboard. Then tried setting it programatically,
self.titleLabel.font = [UIFont fontWithName:@"Farah" size:25];
Has anything changed with the new Xcode that won't allow non-system fonts?
Upvotes: 0
Views: 160
Reputation: 564
Add all non-system fonts to your application and include to .plist file in 'Fonts provided by application' section.
After you can use fonts in your application : [UIFont fontWithName: @"TitilliumText25L-400wt" size:14];
(replacing "TitilliumText25L-400wt" to corresponding font name).
P.S. If you have a problems with detection of real font name use FontBook application or
the code snippet bellow which show you all available fonts for your application.
for(NSString* family in [UIFont familyNames]) {
NSLog(@"%@", family);
for(NSString* name in [UIFont fontNamesForFamilyName: family]) {
NSLog(@" %@", name);
}
}
Upvotes: 2
Reputation: 535566
Getting font names right is not easy. Run this code to learn the available names:
for (NSString* s in [UIFont familyNames])
NSLog(@"%@: %@", s, [UIFont fontNamesForFamilyName:s]);
Of course, if setting a feature of self.titleLabel
does not work, you should also make sure that self.titleLabel
is not nil.
Upvotes: 0
Reputation: 31311
The parameter of fontWithName
must be the real name of the font, not the name of the file.
If you open your ttf file with the Mac Font Book, you will directly see its name on top of the window.
For more, check this out.
Upvotes: 0