It looks like there a few working solutions for using custom true type fonts (ttf) on the iPhone, most notably Can I embed a custom font in an iPhone application? However,
I researched this throughly, and this is the best method I found:
1) Convert font file to TTF using this online tool: http://www.freefontconverter.com/
2) Add the TTF files to your project
3) Make some configurations to your info.plist file:
3.1) Edit info.plist as source code (right click on file -> open as -> source code)
3.2) Add this:
<key>UIAppFonts</key> <array> <string>font1.ttf</string> <string>font2.ttf</string> ...etc... </array>
3.3) Your info.plist should have this now:
4) Use the new fonts just like the system fonts:
[UIFont fontWithName:@"font1" size:16.0];
(Notice no ".ttf" in the font name)
For my own project I wanted to use the opentype font and I basically used this method:
Add your custom font file into your project using XCode as a resource Add a key to your info.plist file (Fonts provided by application) For each font you have, enter the full name of your font file (including the extension) save info.plist then use this for your labels (ex:)
UIFont* font = [UIFont fontWithName:@"Harrowprint" size:20];
In my case @"Harrowprint"
was the filename without the extension and not the font name provided by Finder.
My font was an otf and it worked...so I guess it's supported...or I was lucky. I'll test another font..and keep you posted..
references:
I had trouble with this, too. Here is what worked for me:
NSArray *names = [UIFont fontNamesForFamilyName:@"Foo";
<__NSCFArray 0xe9c4da0>(
Foo-100Italic, Foo-100 )
myLabel.font = [UIFont fontWithName:@"Foo-100Italic" size:24];
This article answers your question (it worked like a charm for me using OTF): http://codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/
OTF is perfectly supported, no need to convert to TTF
With regards to the first answer - the solution is correct (i.e. just convert the font over to TTF) but the software suggested is a super hassle to compile and install. Instead I just did a quick google search and used this instead: http://www.freefontconverter.com/ and that worked perfectly.
(Make sure to add the font to your info.plist file as well)
Must you use an otf font on the device or can you convert it to ttf? It is relatively straightforward to convert an OTF font to a TTF font using a tool such as fontforge, perhaps that would be an easy solution.