Embedding custom fonts

suggest change
Custom Font Support Applications that want to use custom fonts can now include those fonts in their application bundle and register those fonts 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 have been set in the Info.plist, you can use your custom fonts as any other font in IB or programatically.

  1. Drag and drop your font to Xcode Supporting Files folder. Don’t forget to mark your app at “Add to targets” section. From this moment you can use this font in IB and choose it from font pallet.
  1. To make this font available on the device, open Info.plist and add Fonts provided by application key (UIAppFonts). Add font name as the value to the Item 0 key. Note: Font name can vary from your font file name.
  2. Get the custom added font name using below snippet

[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