Last active
December 30, 2015 18:29
-
-
Save chiahsien/7867588 to your computer and use it in GitHub Desktop.
取得字體顯示名稱
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 <CoreText/CoreText.h> // Don't forget to import CoreText | |
NSArray *familyNames = [UIFont familyNames]; | |
for (NSString *familyName in familyNames) { | |
NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName]; | |
for (NSString *fontName in fontNames) { | |
CTFontRef fontRef = CTFontCreateWithName((__bridge CFStringRef)(fontName), 16, NULL); | |
NSString *displayName = CFBridgingRelease(CTFontCopyDisplayName(fontRef)); // Here's the magic... | |
NSLog(@"%@", displayName); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment