Created
February 7, 2013 08:53
-
-
Save MaximKeegan/4729659 to your computer and use it in GitHub Desktop.
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
BOOL GSFontAddFromFile(const char * path); | |
NSUInteger newFontCount = 0; | |
NSBundle *frameworkBundle = [NSBundle bundleWithIdentifier:@"com.apple.GraphicsServices"]; | |
const char *frameworkPath = [[frameworkBundle executablePath] UTF8String]; | |
if (frameworkPath) { | |
void *graphicsServices = dlopen(frameworkPath, RTLD_NOLOAD | RTLD_LAZY); | |
if (graphicsServices) { | |
BOOL (*GSFontAddFromFile)(const char *) = dlsym(graphicsServices, "GSFontAddFromFile"); | |
if (GSFontAddFromFile) { | |
for (NSString *fontFile in [[NSBundle mainBundle] pathsForResourcesOfType:@"otf" inDirectory:nil]) | |
newFontCount += GSFontAddFromFile([fontFile UTF8String]); | |
for (NSString *fontFile in [[NSBundle mainBundle] pathsForResourcesOfType:@"ttf" inDirectory:nil]) | |
newFontCount += GSFontAddFromFile([fontFile UTF8String]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment