Created
November 1, 2013 19:35
-
-
Save programmingthomas/7270732 to your computer and use it in GitHub Desktop.
A simple Objective-C method that will register all of the TTF font files in your application with Core Text.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (void)registerFonts { | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
NSArray * paths = [[NSBundle mainBundle] pathsForResourcesOfType:@"ttf" inDirectory:@""]; | |
for (NSString * path in paths) { | |
NSURL * url = [NSURL fileURLWithPath:path]; | |
CFErrorRef error; | |
CTFontManagerRegisterFontsForURL((__bridge CFURLRef)url, kCTFontManagerScopeNone, &error); | |
error = nil; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment