2

Im using custom font in my application and have run into very weird issue. The font is available on the simulator but unavailable on an actual iPad.

1 I'm not confusing font name and file name. The file name is bitdust2.ttf whereas font name is BitDustTwo and this is how i call it and on simulator it is ok.

2 The is not a question of case sensitivity. The font is really unavailable on the device. I know that cause when i do this:

NSLog(@"%@", [UIFont familyNames]);

i see that on simulator my font is included in the familyNames array, but is missing on the iPad. What's wrong? Did you ever encounter such an issue?

Andrey Chernukha
  • 21,488
  • 17
  • 97
  • 161

5 Answers5

4

(From above comment:) Verify that the font file "bitdust2.ttf" has been added to the target and is copied into the application bundle.

Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382
2

The simulator is, as titled, a simulator, and not a true emulator. The simulator runs the same named APIs, but since the simulator runs on OS X, not iOS, the simulator often has more functionality. For example, the media player classes on the simulator support more types of files (codecs) than on the device because OS X supports more codecs than iOS. On the simulator, you have more Fonts available than on the device.

Here's more details about embedding fonts in an iOS app:

There is a simple way to use custom fonts in iOS 4.

  1. Add your font file (for example, Chalkduster.ttf) to Resources folder of the project in XCode.
  2. Open info.plist and add a new key called UIAppFonts. The type of this key should be array.
  3. Add your custom font name to this array including extension (Chalkduster.ttf).
  4. Now you can use [UIFont fontWithName:@"Chalkduster" size:16] in your application.

It's important not to miss any steps. If you're still having problems, go to the Build Phases tab of your project in XCode and under the Copy Bundle Resources tab, ensure that your font file is included. If not, add it.

Community
  • 1
  • 1
Marcus Adams
  • 53,009
  • 9
  • 91
  • 143
0

Check your device OS version as well as its support for iOs versions. The custom font you used must be compatible with iOS of your device.

Check this answer out. May be you need to have alternate custom font in case it is not supported.

Community
  • 1
  • 1
NightFury
  • 13,436
  • 6
  • 71
  • 120
0

I just had this same problem and after verifying everything was correct:

  • Font is added to proper key in info.plist "Fonts provided by application"
  • Font is added to project -> info under same key as the info.plist (this just means that i saved the plist)
  • Font file is added to the project
  • Font file is in the project folder
  • Project -> target -> Build Phases -> Copy bundle resources: contains my font file
  • File is checked off for being associated with target

I had to download the file again and re-add it.. when i did the file name was changed ... so i think the .ttf file was corrupted

A'sa Dickens
  • 2,045
  • 1
  • 16
  • 21
-1

You'll need to embed the font onto the app; instructions are here.