Last active
December 18, 2015 13:39
-
-
Save yeonsh/5791444 to your computer and use it in GitHub Desktop.
Find file path of system font on OS X
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
... | |
NSLog(@"%@", [self getSystemFontPath:18]); | |
NSLog(@"%s", [self getSystemFontPathCString:18]); | |
... | |
- (const char *)getSystemFontPathCString:(CGFloat)argFontSize | |
{ | |
NSString *path = [self getSystemFontPath:argFontSize]; | |
const char *path_cstring = [path cStringUsingEncoding:[NSString defaultCStringEncoding]]; | |
return path_cstring; | |
} | |
- (NSString *)getSystemFontPath:(CGFloat)argFontSize | |
{ | |
NSFont *sysFont = [NSFont systemFontOfSize:argFontSize]; | |
NSLog(@"%@", [sysFont fontName]); | |
CTFontDescriptorRef fontRef = CTFontDescriptorCreateWithNameAndSize ((__bridge CFStringRef)[sysFont fontName], [sysFont pointSize]); | |
CFURLRef url = (CFURLRef)CTFontDescriptorCopyAttribute(fontRef, kCTFontURLAttribute); | |
NSString *fontPath = [NSString stringWithString:[(__bridge NSURL *)url path]]; | |
CFRelease(fontRef); | |
CFRelease(url); | |
return fontPath; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
font size를 지정할 수 있도록 수정.