]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/fontenum.cpp
remove the drag-and-drop compatibility hack for extracting the embedded size of the...
[wxWidgets.git] / src / mac / carbon / fontenum.cpp
Content-type: text/html ]> git.saurik.com Git - wxWidgets.git/blame - 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 305.
CommitLineData
ee6b1d97 1///////////////////////////////////////////////////////////////////////////////
1089fc00 2// Name: src/mac/carbon/fontenum.cpp
ee6b1d97
SC
3// Purpose: wxFontEnumerator class for MacOS
4// Author: Stefan Csomor
1089fc00 5// Modified by:
ee6b1d97
SC
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
65571936 9// Licence: wxWindows licence
ee6b1d97
SC
10///////////////////////////////////////////////////////////////////////////////
11
ee6b1d97
SC
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
ff427585 15#if wxUSE_FONTENUM
179e085f 16
88a7a4e1
WS
17#include "wx/fontenum.h"
18
ee6b1d97 19#ifndef WX_PRECOMP
88a7a4e1
WS
20 #include "wx/font.h"
21 #include "wx/intl.h"
ee6b1d97
SC
22#endif
23
5b781a67 24#include "wx/fontutil.h"
ee6b1d97 25#include "wx/fontmap.h"
b12ce1d3 26#include "wx/encinfo.h"
ee6b1d97 27
76a5e5d2
SC
28#include "wx/mac/private.h"
29
ee6b1d97 30// ----------------------------------------------------------------------------
753d02e8 31// wxFontEnumerator
ee6b1d97
SC
32// ----------------------------------------------------------------------------
33
753d02e8
SC
34bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding,
35 bool fixedWidthOnly)
ee6b1d97 36{
753d02e8
SC
37 //
38 // From Apple's QA 1471 http://developer.apple.com/qa/qa2006/qa1471.html
39 //
ff427585 40
753d02e8
SC
41 ATSFontFamilyIterator theFontFamilyIterator = NULL;
42 ATSFontFamilyRef theATSFontFamilyRef = 0;
43 OSStatus status = noErr;
ff427585 44
753d02e8 45 wxArrayString fontFamilies ;
ff427585 46
753d02e8
SC
47 // Create the iterator
48 status = ATSFontFamilyIteratorCreate(kATSFontContextLocal, nil,nil,
49 kATSOptionFlagsUnRestrictedScope,
50 &theFontFamilyIterator );
ff427585 51
753d02e8 52 wxUint32 macEncoding = wxMacGetSystemEncFromFontEnc(encoding) ;
ff427585 53
753d02e8 54 while (status == noErr)
e40298d5 55 {
753d02e8
SC
56 // Get the next font in the iteration.
57 status = ATSFontFamilyIteratorNext( theFontFamilyIterator, &theATSFontFamilyRef );
58 if(status == noErr)
e40298d5 59 {
4913272f
SC
60 #ifndef __LP64__
61 // TODO CS : Find replacement
753d02e8
SC
62 // added CS : avoid showing fonts that won't be displayable
63 FMFontStyle intrinsicStyle = 0 ;
64 FMFont fontInstance ;
65 FMFontFamily fmFamily = FMGetFontFamilyFromATSFontFamilyRef( theATSFontFamilyRef );
66 status = FMGetFontFromFontFamilyInstance( fmFamily , 0 , &fontInstance , &intrinsicStyle);
67 if ( status != noErr )
68 {
69 status = noErr;
70 continue ;
71 }
4913272f 72#endif
753d02e8
SC
73 if ( encoding != wxFONTENCODING_SYSTEM )
74 {
75 TextEncoding fontFamiliyEncoding = ATSFontFamilyGetEncoding(theATSFontFamilyRef) ;
76 if ( fontFamiliyEncoding != macEncoding )
77 continue ;
78 }
ff427585 79
753d02e8
SC
80 // TODO: determine fixed widths ...
81
82 CFStringRef theName = NULL;
83 ATSFontFamilyGetName(theATSFontFamilyRef, kATSOptionFlagsDefault, &theName);
84 wxMacCFStringHolder cfName(theName) ;
85 fontFamilies.Add(cfName.AsString(wxLocale::GetSystemEncoding()));
e40298d5 86 }
753d02e8 87