Created
October 7, 2009 22:15
-
-
Save zonble/204496 to your computer and use it in GitHub Desktop.
取得所有 Mac 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
NSArray *a = [[NSFontManager sharedFontManager] availableFonts]; | |
NSMutableArray *tradChineseFontNames = [NSMutableArray array]; | |
NSStringEncoding tradChinese = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingMacChineseTrad); | |
for (NSString *name in a) { | |
NSFont *font = [NSFont fontWithName:name size:12.0]; | |
NSStringEncoding e = [font mostCompatibleStringEncoding]; | |
if (e == tradChinese) { | |
// CFStringRef s = CFStringGetNameOfEncoding(CFStringConvertNSStringEncodingToEncoding(e)); | |
// NSLog(@"name:%@ display name:%@ encoding: %@", name, [font displayName], (NSString *)s); | |
[tradChineseFontNames addObject:name]; | |
} | |
} | |
NSLog(@"tradChineseFontNames:%@", [tradChineseFontNames description]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment