Quick How-To for loading custom fonts in iOS apps:
- Add the font file to your project the same way you would with other files. Some great open source fonts I’m using in an upcoming project are available from The League of Moveable Type.
Edit your info plist to reference the newly added font file (here for example MyFont.otf):
<key>UIAppFonts</key> <array> <string>MyFont.otf</string> </array>
Set the font for the desired view in code, for example:
[self.someLabel setFont:[UIFont fontWithName:@"My Font" size:24.0f]];
NOTE: The tricky part is the font name. The plist needs to reference the font file name such as
UIFont fontWithName: uses the system’s font name, not the file name. Sometimes the system name is very different from the truncated file name such as
OFL Sorts Mill Goudy.