Embedding custom fonts

suggest change

Custom font support: applications that want to use custom fonts can include those fonts in their application bundle and register them with the system by including the UIAppFonts key in their Info.plist file. The value of this key is an array of strings identifying the font files in the application’s bundle. When the system sees the key, it loads the specified fonts and makes them available to the application.

Once the fonts are listed in Info.plist, you can use them like any other font in Interface Builder or in code.

  1. Drag the font file into the Xcode project. Select the app target under Add to targets. The file name in the plist is not enough by itself. The font also has to be in the app target.

  1. To make the font available on the device, open Info.plist and add Fonts provided by application (UIAppFonts). Item 0 is the font file name, including its extension, such as CustomFont.ttf. The name you pass to UIFont(name:) is the PostScript name printed by the snippet below. That name can differ from the file name.

  2. Print the installed family and PostScript names:

Swift 3

for family in UIFont.familyNames {
            print("\(family)")

            for name in UIFont.fontNames(forFamilyName: family) {
                print("   \(name)")
            }
        }

Objective-C

for (NSString *familyName in [UIFont familyNames]){
        NSLog(@"Family name: %@", familyName);
        for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
            NSLog(@"--Font name: %@", fontName);
        }
    }

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents