]>
Commit | Line | Data |
---|---|---|
489468fe | 1 | /////////////////////////////////////////////////////////////////////////////// |
96dabe43 | 2 | // Name: src/osx/core/fontenum.cpp |
489468fe SC |
3 | // Purpose: wxFontEnumerator class for MacOS |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Stefan Csomor | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // For compilers that support precompilation, includes "wx.h". | |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #if wxUSE_FONTENUM | |
16 | ||
17 | #include "wx/fontenum.h" | |
18 | ||
19 | #ifndef WX_PRECOMP | |
20 | #include "wx/font.h" | |
21 | #include "wx/intl.h" | |
22 | #endif | |
23 | ||
24 | #include "wx/fontutil.h" | |
25 | #include "wx/fontmap.h" | |
26 | #include "wx/encinfo.h" | |
27 | ||
1f0c8f31 | 28 | #include "wx/osx/private.h" |
489468fe SC |
29 | |
30 | // ---------------------------------------------------------------------------- | |
31 | // wxFontEnumerator | |
32 | // ---------------------------------------------------------------------------- | |
33 | ||
34 | bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding, | |
35 | bool fixedWidthOnly) | |
36 | { | |
37 | if ( fixedWidthOnly ) | |
38 | { | |
39 | wxFAIL_MSG( "enumerating only fixed width fonts not supported" ); | |
40 | return false; | |
41 | } | |
42 | ||
43 | wxArrayString fontFamilies ; | |
44 | ||
292e5e1f | 45 | #if wxOSX_USE_ATSU_TEXT || wxOSX_USE_CORE_TEXT |
489468fe SC |
46 | |
47 | // | |
48 | // From Apple's QA 1471 http://developer.apple.com/qa/qa2006/qa1471.html | |
49 | // | |
50 | ||
51 | ATSFontFamilyIterator theFontFamilyIterator = NULL; | |
52 | ATSFontFamilyRef theATSFontFamilyRef = 0; | |
53 | OSStatus status = noErr; | |
54 | ||
55 | // Create the iterator | |
56 | status = ATSFontFamilyIteratorCreate(kATSFontContextLocal, nil,nil, | |
57 | kATSOptionFlagsUnRestrictedScope, | |
58 | &theFontFamilyIterator ); | |
59 | ||
60 | wxUint32 macEncoding = wxMacGetSystemEncFromFontEnc(encoding) ; | |
61 | ||
62 | while (status == noErr) | |
63 | { | |
64 | // Get the next font in the iteration. | |
65 | status = ATSFontFamilyIteratorNext( theFontFamilyIterator, &theATSFontFamilyRef ); | |
66 | if(status == noErr) | |
67 | { | |
68 | #ifndef __LP64__ | |
69 | // TODO CS : Find replacement | |
70 | // added CS : avoid showing fonts that won't be displayable | |
71 | FMFontStyle intrinsicStyle = 0 ; | |
72 | FMFont fontInstance ; | |
73 | FMFontFamily fmFamily = FMGetFontFamilyFromATSFontFamilyRef( theATSFontFamilyRef ); | |
74 | status = FMGetFontFromFontFamilyInstance( fmFamily , 0 , &fontInstance , &intrinsicStyle); | |
75 | if ( status != noErr ) | |
76 | { | |
77 | status = noErr; | |
78 | continue ; | |
79 | } | |
80 | #endif | |
81 | if ( encoding != wxFONTENCODING_SYSTEM ) | |
82 | { | |
83 | TextEncoding fontFamiliyEncoding = ATSFontFamilyGetEncoding(theATSFontFamilyRef) ; | |
84 | if ( fontFamiliyEncoding != macEncoding ) | |
85 | continue ; | |
86 | } | |
87 | ||
88 | // TODO: determine fixed widths ... | |
89 | ||
90 | CFStringRef theName = NULL; | |
91 | ATSFontFamilyGetName(theATSFontFamilyRef, kATSOptionFlagsDefault, &theName); | |
92 | wxCFStringRef cfName(theName) ; | |
93 | fontFamilies.Add(cfName.AsString(wxLocale::GetSystemEncoding())); | |
94 | } | |
95 | Content-type: text/html ]>