问题
I have a problem with custom font. Namely it's Tw Cen MT.ttf
It's the same problem as in here: Custom font not showing on device, but does on simulator
Except the given solution doesn't work for me.
I have done exactly what you should do:
- Added Font to Info.plist
- Added Font to Copy Bundle Resources section in Build Phases.
- Used font programmatically by name not filename.
It still doesn't work. What's more interesting - when I list available fonts:
NSLog(@"%@", [UIFont familyNames]);
It shows me my font on simulator but does not show it on the device. I tested it both on the new iPad and iPhone 4 with iOS 6.
Any advice?
回答1:
Be sure not to confuse the family name with the font name. This is the code I use to check the real name of my fonts.-
NSArray *familyNames = [UIFont familyNames];
for (NSString *aFamilyName in familyNames) {
NSArray *fontNames = [UIFont fontNamesForFamilyName:aFamilyName];
for (NSString *aFontName in fontNames) {
NSLog(@"%@", aFontName);
}
}
回答2:
Make sure you got the name of the font right. The simulator is not case sensitive whereas the phone is.
来源:https://stackoverflow.com/questions/15889942/uifont-custom-font-not-displaying-on-device