Pete.Mertz
Pete.Mertz

Reputation: 1301

Loading Custom UIFonts in xCode

So I'm having a couple of problems actually. The first is that I want to use a "Font Suitcase" file as a custom font in an iOS app and haven't been able to get it to work. Not only that, but I haven't been able to properly use a .ttf file either. Here are the steps that I've taken to try and make it work:

  1. Imported the file into my supporting files in xCode.
  2. Added the file name, e.g. "badaboom.TTF" into the Info.plist file
  3. Called UIFont *myFont = [UIFont fontWithName:@"Badaboom" size:20.0];

I also used the code found here to see if the font was even being loaded and it doesn't appear either. This applies for both ttf and font suitcase files.

Any idea what I'm doing wrong?

Thanks, Pete

Upvotes: 3

Views: 2837

Answers (2)

Alexander
Alexander

Reputation: 7238

You have to add your fonts as resources.

So do the following steps:

  • Go to your project settings
  • Select your target
  • Go to Build Phases
  • Add the custom font to Copy Bundle Resources

With this and the code you posted you should now be able to load custom fonts

Upvotes: 10

Matt Hudson
Matt Hudson

Reputation: 7358

Double click on the TTF file in Finder. Look at the title bar. The name inside preview has to be exactly the same as what is in your quote [UIFont fontWithName:@"" size:20.0];

It's case sensitive.

Upvotes: 2

Related Questions