Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Creating font(s) from a URL
//Core Graphics method
CGDataProviderRef provider = CGDataProviderCreateWithURL((__bridge CFURLRef)fontURL);
CGFontRef graphicsFont = CGFontCreateWithDataProvider(provider);
CTFontRef coreTextFont = CTFontCreateWithGraphicsFont(graphicsFont, fontSize, /*matrix*/ NULL, /*attributes*/ NULL);
if (coreTextFont) {
NSFont *font = (__bridge NSFont *)coreTextFont;
[fonts addObject:font];
CFRelease(coreTextFont);
}
CGFontRelease(graphicsFont);
CGDataProviderRelease(provider);
//Pure Core Text method
NSArray *descriptors = (__bridge_transfer NSArray *)CTFontManagerCreateFontDescriptorsFromURL((__bridge CFURLRef)fontURL);
for (NSFontDescriptor *desc in descriptors) {
NSFont *font = [NSFont fontWithDescriptor:desc size:fontSize];
[fonts addObject:font];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.