]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/carbon/fontenum.cpp
remove unneccessary header dependencies on wx/thread.h
[wxWidgets.git] / src / mac / carbon / fontenum.cpp
... / ...
Content-type: text/html ]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/carbon/fontenum.cpp


500 - Internal Server Error

Malformed UTF-8 character (fatal) at /usr/lib/x86_64-linux-gnu/perl5/5.40/HTML/Entities.pm line 485, <$fd> line 93.
CommitLineData
1///////////////////////////////////////////////////////////////////////////////
2// Name: src/mac/carbon/fontenum.cpp
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
28#include "wx/mac/private.h"
29
30// ----------------------------------------------------------------------------
31// wxFontEnumerator
32// ----------------------------------------------------------------------------
33
34bool 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 //
44 // From Apple's QA 1471 http://developer.apple.com/qa/qa2006/qa1471.html
45 //
46
47 ATSFontFamilyIterator theFontFamilyIterator = NULL;
48 ATSFontFamilyRef theATSFontFamilyRef = 0;
49 OSStatus status = noErr;
50
51 wxArrayString fontFamilies ;
52
53 // Create the iterator
54 status = ATSFontFamilyIteratorCreate(kATSFontContextLocal, nil,nil,
55 kATSOptionFlagsUnRestrictedScope,
56 &theFontFamilyIterator );
57
58 wxUint32 macEncoding = wxMacGetSystemEncFromFontEnc(encoding) ;
59
60 while (status == noErr)
61 {
62 // Get the next font in the iteration.
63 status = ATSFontFamilyIteratorNext( theFontFamilyIterator, &theATSFontFamilyRef );
64 if(status == noErr)
65 {
66 #ifndef __LP64__
67 // TODO CS : Find replacement
68 // added CS : avoid showing fonts that won't be displayable
69 FMFontStyle intrinsicStyle = 0 ;
70 FMFont fontInstance ;
71 FMFontFamily fmFamily = FMGetFontFamilyFromATSFontFamilyRef( theATSFontFamilyRef );
72 status = FMGetFontFromFontFamilyInstance( fmFamily , 0 , &fontInstance , &intrinsicStyle);
73 if ( status != noErr )
74 {
75 status = noErr;
76 continue ;
77 }
78#endif
79 if ( encoding != wxFONTENCODING_SYSTEM )
80 {
81 TextEncoding fontFamiliyEncoding = ATSFontFamilyGetEncoding(theATSFontFamilyRef) ;
82 if ( fontFamiliyEncoding != macEncoding )
83 continue ;
84 }
85
86 // TODO: determine fixed widths ...
87
88 CFStringRef theName = NULL;
89 ATSFontFamilyGetName(theATSFontFamilyRef, kATSOptionFlagsDefault, &theName);
90 wxMacCFStringHolder cfName(theName) ;
91 fontFamilies.Add(cfName.AsString(wxLocale::GetSystemEncoding()));
92 }
93