1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/core/fontenum.cpp
3 // Purpose: wxFontEnumerator class for MacOS
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
17 #include "wx/fontenum.h"
24 #include "wx/fontutil.h"
25 #include "wx/fontmap.h"
26 #include "wx/encinfo.h"
28 #include "wx/osx/private.h"
30 // ----------------------------------------------------------------------------
32 // ----------------------------------------------------------------------------
34 bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding
,
39 wxFAIL_MSG( "enumerating only fixed width fonts not supported" );
43 wxArrayString fontFamilies
;
45 #if wxOSX_USE_ATSU_TEXT || wxOSX_USE_CORE_TEXT
48 // From Apple's QA 1471 http://developer.apple.com/qa/qa2006/qa1471.html
51 ATSFontFamilyIterator theFontFamilyIterator
= NULL
;
52 ATSFontFamilyRef theATSFontFamilyRef
= 0;
53 OSStatus status
= noErr
;
55 // Create the iterator
56 status
= ATSFontFamilyIteratorCreate(kATSFontContextLocal
, nil
,nil
,
57 kATSOptionFlagsUnRestrictedScope
,
58 &theFontFamilyIterator
);
60 wxUint32 macEncoding
= wxMacGetSystemEncFromFontEnc(encoding
) ;
62 while (status
== noErr
)
64 // Get the next font in the iteration.
65 status
= ATSFontFamilyIteratorNext( theFontFamilyIterator
, &theATSFontFamilyRef
);
68 if ( encoding
!= wxFONTENCODING_SYSTEM
)
70 TextEncoding fontFamiliyEncoding
= ATSFontFamilyGetEncoding(theATSFontFamilyRef
) ;
71 if ( fontFamiliyEncoding
!= macEncoding
)
75 // TODO: determine fixed widths ...
77 CFStringRef theName
= NULL
;
78 ATSFontFamilyGetName(theATSFontFamilyRef
, kATSOptionFlagsDefault
, &theName
);
79 wxCFStringRef
cfName(theName
) ;
80 fontFamilies
.Add(cfName
.AsString(wxLocale::GetSystemEncoding()));
82 else if (status
== kATSIterationScopeModified
) // Make sure the font database hasn't changed.
85 status
= ATSFontFamilyIteratorReset (kATSFontContextLocal
, nil
, nil
,
86 kATSOptionFlagsUnRestrictedScope
,
87 &theFontFamilyIterator
);
88 fontFamilies
.Clear() ;
91 ATSFontFamilyIteratorRelease(&theFontFamilyIterator
);
94 for ( size_t i
= 0 ; i
< fontFamilies
.Count() ; ++i
)
96 if ( OnFacename( fontFamilies
[i
] ) == false )
103 bool wxFontEnumerator::EnumerateEncodings(const wxString
& WXUNUSED(family
))
105 wxFAIL_MSG(wxT("wxFontEnumerator::EnumerateEncodings() not yet implemented"));
110 #endif // wxUSE_FONTENUM