Skip to content

Instantly share code, notes, and snippets.

@kishikawakatsumi
Created March 31, 2015 09:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kishikawakatsumi/be87a6bf6992f815aa18 to your computer and use it in GitHub Desktop.
Save kishikawakatsumi/be87a6bf6992f815aa18 to your computer and use it in GitHub Desktop.
Register custom download font
#import "ViewController.h"
@import CoreText;
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *DocumentsDirPath = paths.lastObject;
NSURL *fontURL = [NSURL fileURLWithPath:[DocumentsDirPath stringByAppendingPathComponent:@"TTEdit2by3Gothic.ttf"]];
CFErrorRef error = nil;
CTFontManagerRegisterFontsForURL((CFURLRef)fontURL, kCTFontManagerScopeNone, &error);
if (!error) {
UIFont *font = [UIFont fontWithName:@"TTEdit2/3Gothic" size:20.0];
NSLog(@"%@", font);
UILabel *l = [[UILabel alloc] initWithFrame:self.view.frame];
l.text = @"abcdefg";
l.font = font;
[self.view addSubview:l];
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment