3

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:

  1. Added Font to Info.plist
  2. Added Font to Copy Bundle Resources section in Build Phases.
  3. 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?

Community
  • 1
  • 1
Gricha
  • 1,044
  • 3
  • 11
  • 26
  • You should make sure you aren't having the same problem as in that other question by opening up the .app bundle and checking for the font. Or `[[NSBundle mainBundle] pathForResource:ofType:]` in the app. Nothing like knowing for sure that the file is there. – Brendon Apr 08 '13 at 22:33
  • It gives me paths both in simulator and device enviroment. – Gricha Apr 08 '13 at 22:38

2 Answers2

6

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);
     }
}
ssantos
  • 16,001
  • 7
  • 50
  • 70
  • Thank you - it turn's out I had wrong name - it's correct name is TwCenMT-Regular. Still - It's listed when I test on simulator and disappears when running on device. – Gricha Apr 08 '13 at 22:33
  • Ok - you were right with other family name, but I misspelled it while correcting. Thank you! – Gricha Apr 08 '13 at 22:45
1

Make sure you got the name of the font right. The simulator is not case sensitive whereas the phone is.

Fran Sevillano
  • 8,103
  • 4
  • 31
  • 45