Custom Fonts in iOS

Quick How-To for loading custom fonts in iOS apps:

  1. 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.
  2. Edit your info plist to reference the newly added font file (here for example MyFont.otf):

  3. 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 MyFont.otf but 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 OFLGoudyStM-Italic.otf and OFL Sorts Mill Goudy.