Created
December 21, 2012 21:22
-
-
Save codeswimmer/4355925 to your computer and use it in GitHub Desktop.
iOS/OSX: dynamic font loading
This file contains hidden or 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
| NSData *inData = /* your decrypted font-file data */; | |
| CFErrorRef error; | |
| CGDataProviderRef provider = CGDataProviderCreateWithCFData((CFDataRef)inData); | |
| CGFontRef font = CGFontCreateWithDataProvider(provider); | |
| if (! CTFontManagerRegisterGraphicsFont(font, &error)) { | |
| CFStringRef errorDescription = CFErrorCopyDescription(error) | |
| NSLog(@"Failed to load font: %@", errorDescription); | |
| CFRelease(errorDescription); | |
| } | |
| CFRelease(font); | |
| CFRelease(provider); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment