Custom fonts only work if your users have them too. Otherwise, the font needs to be bundled with your program and loaded in a way similar to this one. Always make sure that you are allowed to distribute the font with your program.
-(NSFont*)fontWithName:(NSString*)name height:(CGFloat)height
{
NSURL* fontURL = [NSBundle.mainBundle URLForResource:name withExtension:@"ttf"];
if (fontURL == nil)
{
return nil;
}
CGDataProviderRef dataProvider = CGDataProviderCreateWithURL((CFURLRef)fontURL);
if (dataProvider == NULL)
{
return nil;
}
CTFontRef coreTextFont = NULL;
CGFontRef font = CGFontCreateWithDataProvider(dataProvider);
if (font != NULL)
{
coreTextFont = CTFontCreateWithGraphicsFont(font, height, NULL, NULL);
}
CGDataProviderRelease(dataProvider);
CGFontRelease(font);
return CFBridgingRelease(coreTextFont);
}