Skip to content

Instantly share code, notes, and snippets.

@Quotation
Created February 18, 2014 06:02
Show Gist options
  • Save Quotation/9065427 to your computer and use it in GitHub Desktop.
Save Quotation/9065427 to your computer and use it in GitHub Desktop.
List iOS system font files
// Here are .plist files defining system fonts.
NSFileManager *fileMgr = [NSFileManager defaultManager];
NSArray *files = [fileMgr contentsOfDirectoryAtPath:@"/System/Library/Fonts/" error:NULL];
NSLog(@"%@", files);
// Choose one .plist file. The filename depends on iOS version.
NSDictionary *fontCache = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/Fonts/CGFontCache@2x.plist"];
NSLog(@"%@", fontCache);
// Copy font files to App directory for free access.
NSString *appSupportPath = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject];
[fileMgr createDirectoryAtPath:appSupportPath withIntermediateDirectories:YES attributes:nil error:NULL];
void (^copyFont)(NSString *) = ^(NSString *filename) {
[fileMgr copyItemAtPath:[@"/System/Library/Fonts/Cache/" stringByAppendingPathComponent:filename]
toPath:[appSupportPath stringByAppendingPathComponent:filename]
error:NULL];
};
copyFont(@"STHeiti-Light.ttc");
copyFont(@"_H_HelveticaNeueLights.ttc");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment