diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2009-12-06 22:21:55 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2009-12-06 22:21:55 +0000 |
| commit | b2cffc688ea7abbddabc9ed23deea1921f59ac9d (patch) | |
| tree | 74a50bdb133fd6b5af7c785541bcc46e2e8e9c15 /src/fl_set_fonts_mac.cxx | |
| parent | 1ea4b4573538f2d53960dd8a4ef4f35480d2f5f7 (diff) | |
Moved OS X code base to the more moder Cocoa toolkit thanks to the awesome work of Manolo Gouy (STR #2221). This is a big one! I tested all test applications under 32-bit autoconf and Xcode, and a few apps under 64bit intel. No PPC testing was done. Please verify this patch if you have the machine!
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6951 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/fl_set_fonts_mac.cxx')
| -rw-r--r-- | src/fl_set_fonts_mac.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/fl_set_fonts_mac.cxx b/src/fl_set_fonts_mac.cxx index bb54f5631..84715f1b2 100644 --- a/src/fl_set_fonts_mac.cxx +++ b/src/fl_set_fonts_mac.cxx @@ -60,6 +60,33 @@ static int fl_free_font = FL_FREE_FONT; Fl_Font Fl::set_fonts(const char* xstarname) { #pragma unused ( xstarname ) +#if defined(__APPLE_COCOA__) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 +if(CTFontCreateWithFontDescriptor != NULL) { + int value[1] = {1}; + CFDictionaryRef dict = CFDictionaryCreate(NULL, (const void **)kCTFontCollectionRemoveDuplicatesOption, + (const void **)&value, 1, NULL, NULL); + CTFontCollectionRef fcref = CTFontCollectionCreateFromAvailableFonts(dict); + CFRelease(dict); + CFArrayRef arrayref = CTFontCollectionCreateMatchingFontDescriptors(fcref); + CFRelease(fcref); + CFIndex count = CFArrayGetCount(arrayref); + CFIndex i; + for (i = 0; i < count; i++) { + CTFontDescriptorRef fdesc = (CTFontDescriptorRef)CFArrayGetValueAtIndex(arrayref, i); + CTFontRef font = CTFontCreateWithFontDescriptor(fdesc, 0., NULL); + CFStringRef cfname = CTFontCopyPostScriptName(font); + CFRelease(font); + static char fname[100]; + CFStringGetCString(cfname, fname, sizeof(fname), kCFStringEncodingUTF8); + CFRelease(cfname); + Fl::set_font((Fl_Font)(fl_free_font++), strdup(fname)); + } + CFRelease(arrayref); + return (Fl_Font)fl_free_font; +} +else { +#endif +#if ! __LP64__ #if defined(OLD__APPLE_QUARTZ__) ATSFontIterator it; ATSFontIteratorCreate(kATSFontContextGlobal, 0L, 0L, kATSOptionFlagsUnRestrictedScope, &it); @@ -114,6 +141,10 @@ Fl_Font Fl::set_fonts(const char* xstarname) { } free(oFontIDs); return (Fl_Font)fl_free_font; +#endif //OLD__APPLE_QUARTZ__ +#endif //__LP64__ +#if defined(__APPLE_COCOA__) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + } #endif } |
