Created
March 31, 2015 09:08
-
-
Save kishikawakatsumi/be87a6bf6992f815aa18 to your computer and use it in GitHub Desktop.
Register custom download font
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
#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