views:

1520

answers:

1

I've already seen this post:

http://stackoverflow.com/questions/360751/can-i-embed-a-custom-font-in-an-iphone-application

which is helpful, but I'd love to simply load the font via:

UIFont* font = [UIFont fontWithName:@"Harrowprint" size:20];

Some people have reported this possible but it's not working for me. Can someone confirm how to bundle a custom font with an iphone app?

Also, in the aforementioned post, one answer notes: The "name" of the font is not necessarily the filename.

How do I determine the "name" of the font that would be recognized by UIFont? It's possible i'm not using the correct name.

+3  A: 

There are several steps you need to take:

1) Make sure you have the rights to distribute the font. Most fonts -- even free ones -- do not allow you to distribute them. Putting them in your app most likely consitutes 'distribution' and would be considered illegal.

2) Copy the font to your Resources folder in your app. Make sure it's in your Copy Files build phase.

3) Get the 'name' of the font by putting in a temporary line of code:

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

Build and run the app. This will print to the Console the family names of all the fonts on the device. Find the one that matches your font.

You can then use that font name in the fontWithName: method.

August
Are you sure this is right? I tried doing this, and all I got was the normal list of fonts.
Ben Alpert
Correct - it only prints out the name of standard fonts. Not custom ones.
4thSpace
This does not work.
Mike Weller