Skip to content

Instantly share code, notes, and snippets.

@draftcode
Created August 12, 2011 08:55
Show Gist options
  • Select an option

  • Save draftcode/1141730 to your computer and use it in GitHub Desktop.

Select an option

Save draftcode/1141730 to your computer and use it in GitHub Desktop.
#include <Carbon/Carbon.h>
int main(void) {
CTFontCollectionRef collection = CTFontCollectionCreateFromAvailableFonts(NULL);
if (collection) {
CFArrayRef array = CTFontCollectionCreateMatchingFontDescriptors(collection);
CFIndex arrayNum = CFArrayGetCount(array);
for (CFIndex i = 0; i < arrayNum; i++) {
CFStringRef attribute = CTFontDescriptorCopyAttribute(
CFArrayGetValueAtIndex(array, i), kCTFontNameAttribute);
const char *data = CFStringGetCStringPtr(attribute, kCFStringEncodingMacRoman);
if (data) {
printf("%s\n", data);
}
CFRelease(attribute);
}
CFRelease(array);
CFRelease(collection);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment