How to include a font in an application for iPhone?

I already saw this post:

Can I embed my own font in an iPhone app?

which is useful, but I would just like to download the font via:

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

Some people have reported this, but this does not work for me. Can someone confirm how to associate custom font with iphone app?

In addition, in the above post, one response notes: The "name" of the font is not necessarily the name of the file.

How to determine the "name" of a font that will be recognized by UIFont? Perhaps I am not using the correct name.

+7
iphone cocoa-touch
source share
2 answers

You need to take a few steps:

1) Make sure you have font distribution rights. Most fonts - even free ones - do not allow you to distribute them. Including them in your application is likely to be โ€œdistributedโ€ and considered illegal.

2) Copy the font to the "Resources" folder in the application. Make sure it is in the build phase of the copy files.

3) Add the "Fonts provided by the application" key to the plist file and add the full name of the font file (including the extension)

4) Get the "name" of the font by inserting a temporary line of code:

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

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

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

+13
source share

To add the answer to August above, you need to add the "Fonts provided by the application" key to the plist file and add the full font file name (including the extension). The font will then appear in the family printout, and you can use this name to set the font.

+5
source share

All Articles