desktop
tablet
mobile
mobile-wide

Use Fonts / iOS

Use Mobile FontFonts on iOS in 4 Steps

It is easy to use custom application-provided fonts in an iOS application. For UIControls exposing the font property and your own components drawing their content it is a matter of getting a UIFont property. You can find a working example application at our github project page.


Add your custom font files to the project

Add the font files you want to use by dragging them into the project navigator. You can put them anywhere, XCode automatically adds them to the resource bundle of the built product. But to keep things orderly, the best place is probably a separate group named “Fonts” in your file tree. iOS supports TrueType (.ttf) and OpenType (.otf) files. Naturally, Mobile FontFonts are in the right format.


Edit your info.plist file

Open the info.plist file of your application. Then add the key “Fonts provided by application” to your Application.plist file (the non-human readable term for this key is “UIAPPFonts”). This key should be of type “Array”. Add each font file name to the Array as a String entry.


Get a UIFont reference and use it

With that administrative stuff out of the way, it’s possible to get a UIFont reference like this:

UIFont* font = [UIFont fontWithName:@"SuperFont Medium" size:24];

Armed with that font reference, you can set the font property exposed by UIControls, like UILabel:

UILabel* label = ...
label.font = font;

Here is a code snippet to list all fonts available to the app:

// Get all the fonts on the system
NSArray *familyNames = [UIFont familyNames];
for( NSString *familyName in familyNames ){
    printf( "Family: %s \n", [familyName UTF8String] );
    NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName];
    for( NSString *fontName in fontNames ){
        printf( "\tFont: %s \n", [fontName UTF8String] );
    }
}


Check out our sample code hosted at github.

We have prepared a sample application which has examples for a few use cases. From easy property setting to slightly more advanced stuff like text layers and workarounds for some UIControls, get your code here. (psst – It also comes with a free font).

Post a question
Questions? Ask us!

Our customer support team is here to serve you.

Post a question