1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/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/mac/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 wxMAC_USE_ATSU_TEXT || wxMAC_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
);
69 // TODO CS : Find replacement
70 // added CS : avoid showing fonts that won't be displayable
71 FMFontStyle intrinsicStyle
= 0 ;
73 FMFontFamily fmFamily
= FMGetFontFamilyFromATSFontFamilyRef( theATSFontFamilyRef
);
74 status
= FMGetFontFromFontFamilyInstance( fmFamily
, 0 , &fontInstance
, &intrinsicStyle
);
75 if ( status
!= noErr
)
81 if ( encoding
!= wxFONTENCODING_SYSTEM
)
83 TextEncoding fontFamiliyEncoding
= ATSFontFamilyGetEncoding(theATSFontFamilyRef
) ;
84 if ( fontFamiliyEncoding
!= macEncoding
)
88 // TODO: determine fixed widths ...
90 CFStringRef theName
= NULL
;
91 ATSFontFamilyGetName(theATSFontFamilyRef
, kATSOptionFlagsDefault
, &theName
);
92 wxCFStringRef
cfName(theName
) ;
93 fontFamilies
.Add(cfName
.AsString(wxLocale::GetSystemEncoding()));
95 else if (status
== kATSIterationScopeModified
) // Make sure the font database hasnÕt changed.
98 status
= ATSFontFamilyIteratorReset (kATSFontContextLocal
, nil
, nil
,
99 kATSOptionFlagsUnRestrictedScope
,
100 &theFontFamilyIterator
);
101 fontFamilies
.Clear() ;
104 ATSFontFamilyIteratorRelease(&theFontFamilyIterator
);
107 for ( size_t i
= 0 ; i
< fontFamilies
.Count() ; ++i
)
109 if ( OnFacename( fontFamilies
[i
] ) == false )
116 bool wxFontEnumerator::EnumerateEncodings(const wxString
& WXUNUSED(family
))
118 wxFAIL_MSG(wxT("wxFontEnumerator::EnumerateEncodings() not yet implemented"));
123 #endif // wxUSE_FONTENUM