Skip to content

Instantly share code, notes, and snippets.

@zonble
Created October 7, 2009 22:15
Show Gist options
  • Save zonble/204496 to your computer and use it in GitHub Desktop.
Save zonble/204496 to your computer and use it in GitHub Desktop.
取得所有 Mac OS X 中可用之繁體中文字體列表
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