Skip to content

Instantly share code, notes, and snippets.

@yeonsh
Last active December 18, 2015 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yeonsh/5791444 to your computer and use it in GitHub Desktop.
Save yeonsh/5791444 to your computer and use it in GitHub Desktop.
Find file path of system font on OS X
...
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;
}
@yeonsh
Copy link
Author

yeonsh commented Jun 16, 2013

font size를 지정할 수 있도록 수정.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment