Created
February 18, 2014 06:02
-
-
Save Quotation/9065427 to your computer and use it in GitHub Desktop.
List iOS system font files
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
// 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