Evadne Wu :: Human Interface & Technical Delivery Specialist

Loading 2+ fonts on iOS from the same font family

There is an UIKit bug where if you pass more than 2 fonts of the same family thru UIAppFonts in the Info.plist only the first 2 will be handled.

Don’t use UIAppFonts, it’s still buggy on iOS 6.1. Instead, build your own intelligent scanner-loader with CTFontManager (in Core Text) and some UTI type matching (in MobileCoreServices on iOS).

    CTFontManagerRegisterFontsForURLs((__bridge CFArrayRef)((^{
        NSFileManager *fileManager = [NSFileManager defaultManager];
        NSURL *resourceURL = [[NSBundle mainBundle] resourceURL];
        NSArray *resourceURLs = [fileManager contentsOfDirectoryAtURL:resourceURL includingPropertiesForKeys:nil options:0 error:nil];
        return [resourceURLs filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSURL *url, NSDictionary *bindings) {
            CFStringRef pathExtension = (__bridge CFStringRef)[url pathExtension];
            NSArray *allIdentifiers = (__bridge_transfer NSArray *)UTTypeCreateAllIdentifiersForTag(kUTTagClassFilenameExtension, pathExtension, CFSTR("public.font"));
            if (![allIdentifiers count]) {
                return NO;
            CFStringRef utType = (__bridge CFStringRef)[allIdentifiers lastObject];
            return (!CFStringHasPrefix(utType, CFSTR("dyn.")) && UTTypeConformsTo(utType, CFSTR("public.font")));
    })()), kCTFontManagerScopeProcess, nil);

Put this paragraph before you make any views, preferrably within -application:didFinishLaunchingWithOptions: and it’ll do its own thing.