1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/font.cpp
3 // Purpose: wxFont class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
17 #include "wx/string.h"
20 #include "wx/gdicmn.h"
24 #include "wx/fontutil.h"
25 #include "wx/graphics.h"
27 #include "wx/mac/uma.h"
30 #include <ATSUnicode.h>
36 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
39 class WXDLLEXPORT wxFontRefData
: public wxGDIRefData
44 Init(10, wxDEFAULT
, wxNORMAL
, wxNORMAL
,
45 false, wxT("applicationfont"), wxFONTENCODING_DEFAULT
);
48 wxFontRefData(const wxFontRefData
& data
)
50 Init(data
.m_pointSize
, data
.m_family
, data
.m_style
, data
.m_weight
,
51 data
.m_underlined
, data
.m_faceName
, data
.m_encoding
);
54 wxFontRefData(int size
,
59 const wxString
& faceName
,
60 wxFontEncoding encoding
)
62 Init(size
, family
, style
, weight
, underlined
, faceName
, encoding
);
65 #if wxMAC_USE_CORE_TEXT
66 wxFontRefData( wxUint32 coreTextFontType
);
67 wxFontRefData( CTFontRef font
);
68 wxFontRefData( CTFontDescriptorRef fontdescriptor
, int size
);
71 virtual ~wxFontRefData();
73 void SetNoAntiAliasing( bool no
= true ) { m_noAA
= no
; }
75 bool GetNoAntiAliasing() const { return m_noAA
; }
77 void SetPointSize( int size
)
80 MacInvalidateNativeFont();
83 int GetPointSize() const { return m_pointSize
; }
85 void SetFamily( int family
)
88 MacInvalidateNativeFont();
92 int GetFamily() const { return m_family
; }
94 void SetStyle( int style
)
97 MacInvalidateNativeFont();
101 int GetStyle() const { return m_style
; }
103 void SetWeight( int weight
)
106 MacInvalidateNativeFont();
110 int GetWeight() const { return m_weight
; }
112 void SetUnderlined( bool u
)
115 MacInvalidateNativeFont();
118 bool GetUnderlined() const { return m_underlined
; }
120 void SetFaceName( const wxString
& facename
)
122 m_faceName
= facename
;
123 MacInvalidateNativeFont();
126 const wxString
& GetFaceName() const { return m_faceName
; }
128 void SetEncoding( wxFontEncoding encoding
)
130 m_encoding
= encoding
;
131 MacInvalidateNativeFont();
134 wxFontEncoding
GetEncoding() const { return m_encoding
; }
136 void MacInvalidateNativeFont();
141 // common part of all ctors
147 const wxString
& faceName
,
148 wxFontEncoding encoding
);
150 #if wxMAC_USE_CORE_TEXT
151 void Init( CTFontRef font
);
153 // font characterstics
160 wxFontEncoding m_encoding
;
161 bool m_noAA
; // No anti-aliasing
164 #if wxMAC_USE_ATSU_TEXT
165 FMFontFamily m_macFontFamily
;
166 FMFontSize m_macFontSize
;
167 FMFontStyle m_macFontStyle
;
169 // ATSU Font Information
171 // this is split into an ATSU font id that may
172 // contain some styles (special bold fonts etc) and
173 // these are the additional qd styles that are not
174 // included in the ATSU font id
175 ATSUFontID m_macATSUFontID
;
176 FMFontStyle m_macATSUAdditionalQDStyles
;
178 // for true themeing support we must store the correct font
179 // information here, as this speeds up and optimizes rendering
180 ThemeFontID m_macThemeFontID
;
182 #if wxMAC_USE_CORE_TEXT
183 wxCFRef
<CTFontRef
> m_ctFont
;
184 wxCFRef
<CTFontDescriptorRef
> m_ctFontDescriptor
;
186 #if wxMAC_USE_CORE_TEXT || wxMAC_USE_ATSU_TEXT
187 ATSUStyle m_macATSUStyle
;
189 wxNativeFontInfo m_info
;
192 #define M_FONTDATA ((wxFontRefData*)m_refData)
195 // ============================================================================
197 // ============================================================================
199 // ----------------------------------------------------------------------------
201 // ----------------------------------------------------------------------------
203 void wxFontRefData::Init(int pointSize
,
208 const wxString
& faceName
,
209 wxFontEncoding encoding
)
212 m_pointSize
= pointSize
;
216 m_underlined
= underlined
;
217 m_faceName
= faceName
;
218 m_encoding
= encoding
;
220 #if wxMAC_USE_ATSU_TEXT
221 m_macFontFamily
= 0 ;
225 m_macATSUAdditionalQDStyles
= 0 ;
226 m_macThemeFontID
= kThemeCurrentPortFont
;
228 #if wxMAC_USE_CORE_TEXT || wxMAC_USE_ATSU_TEXT
229 m_macATSUStyle
= NULL
;
233 wxFontRefData::~wxFontRefData()
235 #if wxMAC_USE_CORE_TEXT || wxMAC_USE_ATSU_TEXT
236 if ( m_macATSUStyle
)
238 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
239 m_macATSUStyle
= NULL
;
244 void wxFontRefData::MacInvalidateNativeFont()
246 #if wxMAC_USE_CORE_TEXT
248 m_ctFontDescriptor
.reset();
250 #if wxMAC_USE_CORE_TEXT || wxMAC_USE_ATSU_TEXT
251 if ( m_macATSUStyle
)
253 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
254 m_macATSUStyle
= NULL
;
259 #if wxMAC_USE_CORE_TEXT
261 /* from Core Text Manual Common Operations */
263 static CTFontDescriptorRef
wxMacCreateCTFontDescriptor(CFStringRef iFamilyName
, CTFontSymbolicTraits iTraits
)
265 CTFontDescriptorRef descriptor
= NULL
;
266 CFMutableDictionaryRef attributes
;
268 assert(iFamilyName
!= NULL
);
269 // Create a mutable dictionary to hold our attributes.
270 attributes
= CFDictionaryCreateMutable(kCFAllocatorDefault
, 0,
271 &kCFTypeDictionaryKeyCallBacks
, &kCFTypeDictionaryValueCallBacks
);
272 check(attributes
!= NULL
);
274 if (attributes
!= NULL
) {
275 // Add a family name to our attributes.
276 CFDictionaryAddValue(attributes
, kCTFontFamilyNameAttribute
, iFamilyName
);
280 CFMutableDictionaryRef traits
;
281 CFNumberRef symTraits
;
283 // Create the traits dictionary.
284 symTraits
= CFNumberCreate(kCFAllocatorDefault
, kCFNumberSInt32Type
,
286 check(symTraits
!= NULL
);
288 if (symTraits
!= NULL
) {
289 // Create a dictionary to hold our traits values.
290 traits
= CFDictionaryCreateMutable(kCFAllocatorDefault
, 0,
291 &kCFTypeDictionaryKeyCallBacks
, &kCFTypeDictionaryValueCallBacks
);
292 check(traits
!= NULL
);
294 if (traits
!= NULL
) {
295 // Add the symbolic traits value to the traits dictionary.
296 CFDictionaryAddValue(traits
, kCTFontSymbolicTrait
, symTraits
);
298 // Add the traits attribute to our attributes.
299 CFDictionaryAddValue(attributes
, kCTFontTraitsAttribute
, traits
);
302 CFRelease(symTraits
);
305 // Create the font descriptor with our attributes
306 descriptor
= CTFontDescriptorCreateWithAttributes(attributes
);
307 check(descriptor
!= NULL
);
309 CFRelease(attributes
);
311 // Return our font descriptor.
315 wxFontRefData::wxFontRefData( wxUint32 coreTextFontType
)
317 CTFontRef font
= CTFontCreateUIFontForLanguage( coreTextFontType
, 0.0, NULL
) ;
318 if ( CTFontGetSize(m_ctFont
) == 0 )
321 font
= CTFontCreateUIFontForLanguage( coreTextFontType
, 12.0, NULL
);
326 wxFontRefData::wxFontRefData( CTFontRef font
)
331 wxFontRefData::wxFontRefData( CTFontDescriptorRef fontdescriptor
, int size
)
335 wxCFRef
< CFNumberRef
> value( (CFNumberRef
) CTFontDescriptorCopyAttribute( fontdescriptor
, kCTFontSizeAttribute
) );
338 if ( CFNumberGetValue( value
, kCFNumberFloatType
, &fsize
) )
340 size
= (int) fsize
+ 0.5 ;
343 Init( CTFontCreateWithFontDescriptor(fontdescriptor
, size
,NULL
) );
346 void wxFontRefData::Init( CTFontRef font
)
348 Init(10, wxDEFAULT
, wxNORMAL
, wxNORMAL
,
349 false, wxT("applicationfont"), wxFONTENCODING_DEFAULT
);
351 m_ctFont
.reset( font
);
356 void wxFontRefData::MacFindFont()
359 #if wxMAC_USE_CORE_TEXT
360 if ( UMAGetSystemVersion() >= 0x1050 )
362 if ( m_faceName
.empty() && m_family
== wxDEFAULT
)
364 m_ctFont
.reset(CTFontCreateUIFontForLanguage( kCTFontSystemFontType
, 0.0, NULL
));
369 wxCFStringRef
name( CTFontCopyFamilyName( m_ctFont
) );
370 m_faceName
= name
.AsString();
371 m_pointSize
= CTFontGetSize(m_ctFont
) ;
372 CTFontSymbolicTraits traits
= CTFontGetSymbolicTraits( m_ctFont
);
373 if ( traits
& kCTFontItalicTrait
)
375 if ( traits
& kCTFontBoldTrait
)
377 if ( !m_ctFontDescriptor
.get() )
378 m_ctFontDescriptor
.reset( CTFontCopyFontDescriptor( m_ctFont
) );
382 if ( m_faceName
.empty() )
389 m_faceName
= wxT("Times");
393 m_faceName
= wxT("Lucida Grande");
398 m_faceName
= wxT("Monaco");
402 m_faceName
= wxT("Times");
408 CTFontSymbolicTraits traits
= 0;
410 if (m_weight
== wxBOLD
)
411 traits
|= kCTFontBoldTrait
;
412 if (m_style
== wxITALIC
|| m_style
== wxSLANT
)
413 traits
|= kCTFontItalicTrait
;
415 // use font descriptor caching
417 wxString lookupname
= wxString::Format( "%s_%ld", m_faceName
.c_str(), traits
);
419 static std::map
< std::wstring
, wxCFRef
< CTFontDescriptorRef
> > fontdescriptorcache
;
421 m_ctFontDescriptor
= fontdescriptorcache
[ std::wstring(lookupname
.wc_str()) ];
422 if ( !m_ctFontDescriptor
)
424 wxCFStringRef
cf( m_faceName
, wxLocale::GetSystemEncoding() );
425 m_ctFontDescriptor
.reset( wxMacCreateCTFontDescriptor( cf
, traits
) );
426 fontdescriptorcache
[ std::wstring(lookupname
.wc_str()) ] = m_ctFontDescriptor
;
429 wxCFStringRef
cf( m_faceName
, wxLocale::GetSystemEncoding() );
430 m_ctFontDescriptor
.reset( wxMacCreateCTFontDescriptor( cf
, traits
) );
435 wxString lookupnameWithSize
= wxString::Format( "%s_%ld_%ld", m_faceName
.c_str(), traits
, m_pointSize
);
437 static std::map
< std::wstring
, wxCFRef
< CTFontRef
> > fontcache
;
438 m_ctFont
= fontcache
[ std::wstring(lookupnameWithSize
.wc_str()) ];
441 m_ctFont
.reset( CTFontCreateWithFontDescriptor( m_ctFontDescriptor
, m_pointSize
, NULL
) );
442 fontcache
[ std::wstring(lookupnameWithSize
.wc_str()) ] = m_ctFont
;
445 m_ctFont
.reset( CTFontCreateWithFontDescriptor( m_ctFontDescriptor
, m_pointSize
, NULL
) );
448 #if wxMAC_USE_ATSU_TEXT == 0
449 OSStatus status
= noErr
;
450 CTFontDescriptorRef desc
= m_ctFontDescriptor
;
451 ATSFontRef atsfont
= CTFontGetPlatformFont( m_ctFont
, &desc
);
452 FMFont fmfont
= FMGetFontFromATSFontRef( atsfont
);
453 ATSUAttributeTag atsuTags
[] =
457 kATSUVerticalCharacterTag
,
460 kATSUQDUnderlineTag
,
462 ByteCount atsuSizes
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
464 sizeof( ATSUFontID
) ,
466 sizeof( ATSUVerticalCharacterType
),
471 Boolean kTrue
= true ;
472 Boolean kFalse
= false ;
474 Fixed atsuSize
= IntToFixed( m_pointSize
);
475 ATSUVerticalCharacterType kHorizontal
= kATSUStronglyHorizontal
;
476 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
481 (m_weight
== wxBOLD
) ? &kTrue
: &kFalse
,
482 (m_style
== wxITALIC
|| m_style
== wxSLANT
) ? &kTrue
: &kFalse
,
483 (m_underlined
) ? &kTrue
: &kFalse
,
486 if ( m_macATSUStyle
)
488 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
489 m_macATSUStyle
= NULL
;
491 status
= ::ATSUCreateStyle((ATSUStyle
*)&m_macATSUStyle
);
492 wxASSERT_MSG( status
== noErr
, wxT("couldn't create ATSU style") );
493 status
= ::ATSUSetAttributes(
494 (ATSUStyle
)m_macATSUStyle
,
495 sizeof(atsuTags
) / sizeof(ATSUAttributeTag
) ,
496 atsuTags
, atsuSizes
, atsuValues
);
500 #if wxMAC_USE_ATSU_TEXT
502 OSStatus status
= noErr
;
504 if ( m_macThemeFontID
!= kThemeCurrentPortFont
)
507 GetThemeFont( m_macThemeFontID
, GetApplicationScript(), qdFontName
, &m_macFontSize
, &style
);
508 if ( m_macFontSize
== 0 )
510 m_macFontStyle
= style
;
511 m_faceName
= wxMacMakeStringFromPascal( qdFontName
);
512 if ( m_macFontStyle
& bold
)
515 m_weight
= wxNORMAL
;
516 if ( m_macFontStyle
& italic
)
518 if ( m_macFontStyle
& underline
)
519 m_underlined
= true ;
520 m_pointSize
= m_macFontSize
;
521 m_macFontFamily
= FMGetFontFamilyFromName( qdFontName
);
525 if ( m_faceName
.empty() )
527 if ( m_family
== wxDEFAULT
)
529 m_macFontFamily
= GetAppFont();
530 FMGetFontFamilyName(m_macFontFamily
,qdFontName
);
531 m_faceName
= wxMacMakeStringFromPascal( qdFontName
);
540 m_faceName
= wxT("Times");
544 m_faceName
= wxT("Lucida Grande");
549 m_faceName
= wxT("Monaco");
553 m_faceName
= wxT("Times");
556 wxMacStringToPascal( m_faceName
, qdFontName
);
557 m_macFontFamily
= FMGetFontFamilyFromName( qdFontName
);
558 if ( m_macFontFamily
== kInvalidFontFamily
)
560 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for %s"), m_faceName
.c_str() );
561 m_macFontFamily
= GetAppFont();
567 if ( m_faceName
== wxT("systemfont") )
568 m_macFontFamily
= GetSysFont();
569 else if ( m_faceName
== wxT("applicationfont") )
570 m_macFontFamily
= GetAppFont();
573 wxCFStringRef
cf( m_faceName
, wxLocale::GetSystemEncoding() );
574 ATSFontFamilyRef atsfamily
= ATSFontFamilyFindFromName( cf
, kATSOptionFlagsDefault
);
575 if ( atsfamily
== (ATSFontFamilyRef
) -1 )
577 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for ") + m_faceName
);
578 m_macFontFamily
= GetAppFont();
581 m_macFontFamily
= FMGetFontFamilyFromATSFontFamilyRef( atsfamily
);
586 if (m_weight
== wxBOLD
)
587 m_macFontStyle
|= bold
;
588 if (m_style
== wxITALIC
|| m_style
== wxSLANT
)
589 m_macFontStyle
|= italic
;
591 m_macFontStyle
|= underline
;
592 m_macFontSize
= m_pointSize
;
595 // we try to get as much styles as possible into ATSU
598 // ATSUFontID and FMFont are equivalent
599 FMFontStyle intrinsicStyle
= 0 ;
600 status
= FMGetFontFromFontFamilyInstance( m_macFontFamily
, m_macFontStyle
, &m_macATSUFontID
, &intrinsicStyle
);
601 wxASSERT_MSG( status
== noErr
, wxT("couldn't get an ATSUFont from font family") );
602 m_macATSUAdditionalQDStyles
= m_macFontStyle
& (~intrinsicStyle
);
604 if ( m_macATSUStyle
)
606 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
607 m_macATSUStyle
= NULL
;
610 status
= ::ATSUCreateStyle((ATSUStyle
*)&m_macATSUStyle
);
611 wxASSERT_MSG( status
== noErr
, wxT("couldn't create ATSU style") );
613 ATSUAttributeTag atsuTags
[] =
617 kATSUVerticalCharacterTag
,
620 kATSUQDUnderlineTag
,
621 kATSUQDCondensedTag
,
624 ByteCount atsuSizes
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
626 sizeof( ATSUFontID
) ,
628 sizeof( ATSUVerticalCharacterType
),
636 Boolean kTrue
= true ;
637 Boolean kFalse
= false ;
639 Fixed atsuSize
= IntToFixed( m_macFontSize
);
640 ATSUVerticalCharacterType kHorizontal
= kATSUStronglyHorizontal
;
641 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
646 (m_macATSUAdditionalQDStyles
& bold
) ? &kTrue
: &kFalse
,
647 (m_macATSUAdditionalQDStyles
& italic
) ? &kTrue
: &kFalse
,
648 (m_macATSUAdditionalQDStyles
& underline
) ? &kTrue
: &kFalse
,
649 (m_macATSUAdditionalQDStyles
& condense
) ? &kTrue
: &kFalse
,
650 (m_macATSUAdditionalQDStyles
& extend
) ? &kTrue
: &kFalse
,
653 status
= ::ATSUSetAttributes(
654 (ATSUStyle
)m_macATSUStyle
,
655 sizeof(atsuTags
) / sizeof(ATSUAttributeTag
) ,
656 atsuTags
, atsuSizes
, atsuValues
);
658 wxASSERT_MSG( status
== noErr
, wxT("couldn't modify ATSU style") );
664 // ----------------------------------------------------------------------------
666 // ----------------------------------------------------------------------------
668 bool wxFont::Create(const wxNativeFontInfo
& info
)
671 info
.pointSize
, info
.family
, info
.style
, info
.weight
,
672 info
.underlined
, info
.faceName
, info
.encoding
);
675 wxFont::wxFont(const wxString
& fontdesc
)
677 wxNativeFontInfo info
;
678 if ( info
.FromString(fontdesc
) )
682 bool wxFont::Create(int pointSize
,
687 const wxString
& faceName
,
688 wxFontEncoding encoding
)
692 m_refData
= new wxFontRefData(
693 pointSize
, family
, style
, weight
,
694 underlined
, faceName
, encoding
);
701 #if wxMAC_USE_CORE_TEXT
703 bool wxFont::MacCreateFromUIFont(wxUint32 ctFontType
)
707 m_refData
= new wxFontRefData(ctFontType
);
713 bool wxFont::MacCreateFromCTFontDescriptor( const void * ctFontDescriptor
, int size
)
717 m_refData
= new wxFontRefData((CTFontDescriptorRef
)ctFontDescriptor
, size
);;
726 bool wxFont::MacCreateFromThemeFont(wxUint16 themeFontID
)
728 #if wxMAC_USE_CORE_TEXT
729 if ( UMAGetSystemVersion() >= 0x1050)
731 return MacCreateFromUIFont(HIThemeGetUIFontType(themeFontID
));
734 #if wxMAC_USE_ATSU_TEXT
738 m_refData
= new wxFontRefData(
739 12, wxDEFAULT
, wxFONTSTYLE_NORMAL
, wxFONTWEIGHT_NORMAL
,
740 false, wxEmptyString
, wxFONTENCODING_DEFAULT
);
742 M_FONTDATA
->m_macThemeFontID
= themeFontID
;
754 bool wxFont::RealizeResource()
756 M_FONTDATA
->MacFindFont();
761 void wxFont::SetEncoding(wxFontEncoding encoding
)
765 M_FONTDATA
->SetEncoding( encoding
);
770 void wxFont::Unshare()
772 // Don't change shared data
775 m_refData
= new wxFontRefData();
779 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
785 wxGDIRefData
*wxFont::CreateGDIRefData() const
787 return new wxFontRefData
;
790 wxGDIRefData
*wxFont::CloneGDIRefData(const wxGDIRefData
*data
) const
792 return new wxFontRefData(*wx_static_cast(const wxFontRefData
*, data
));
795 void wxFont::SetPointSize(int pointSize
)
797 if ( M_FONTDATA
->GetPointSize() == pointSize
)
802 M_FONTDATA
->SetPointSize( pointSize
);
807 void wxFont::SetFamily(int family
)
811 M_FONTDATA
->SetFamily( family
);
816 void wxFont::SetStyle(int style
)
820 M_FONTDATA
->SetStyle( style
);
825 void wxFont::SetWeight(int weight
)
829 M_FONTDATA
->SetWeight( weight
);
834 bool wxFont::SetFaceName(const wxString
& faceName
)
838 M_FONTDATA
->SetFaceName( faceName
);
842 return wxFontBase::SetFaceName(faceName
);
845 void wxFont::SetUnderlined(bool underlined
)
849 M_FONTDATA
->SetUnderlined( underlined
);
854 void wxFont::SetNoAntiAliasing( bool no
)
858 M_FONTDATA
->SetNoAntiAliasing( no
);
863 // ----------------------------------------------------------------------------
865 // ----------------------------------------------------------------------------
867 // TODO: insert checks everywhere for M_FONTDATA == NULL!
869 int wxFont::GetPointSize() const
871 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
873 return M_FONTDATA
->GetPointSize();
876 wxSize
wxFont::GetPixelSize() const
878 #if wxUSE_GRAPHICS_CONTEXT
879 // TODO: consider caching the value
880 wxGraphicsContext
* dc
= wxGraphicsContext::CreateFromNative((CGContextRef
) NULL
);
881 dc
->SetFont(*(wxFont
*)this,*wxBLACK
);
882 wxDouble width
, height
= 0;
883 dc
->GetTextExtent( wxT("g"), &width
, &height
, NULL
, NULL
);
885 return wxSize((int)width
, (int)height
);
887 return wxFontBase::GetPixelSize();
891 int wxFont::GetFamily() const
893 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
895 return M_FONTDATA
->GetFamily();
898 int wxFont::GetStyle() const
900 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
902 return M_FONTDATA
->GetStyle() ;
905 int wxFont::GetWeight() const
907 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
909 return M_FONTDATA
->GetWeight();
912 bool wxFont::GetUnderlined() const
914 wxCHECK_MSG( M_FONTDATA
!= NULL
, false, wxT("invalid font") );
916 return M_FONTDATA
->GetUnderlined();
919 wxString
wxFont::GetFaceName() const
921 wxCHECK_MSG( M_FONTDATA
!= NULL
, wxEmptyString
, wxT("invalid font") );
923 return M_FONTDATA
->GetFaceName() ;
926 wxFontEncoding
wxFont::GetEncoding() const
928 wxCHECK_MSG( M_FONTDATA
!= NULL
, wxFONTENCODING_DEFAULT
, wxT("invalid font") );
930 return M_FONTDATA
->GetEncoding() ;
933 bool wxFont::GetNoAntiAliasing() const
935 wxCHECK_MSG( M_FONTDATA
!= NULL
, false, wxT("invalid font") );
937 return M_FONTDATA
->GetNoAntiAliasing();
940 #if wxMAC_USE_ATSU_TEXT
942 short wxFont::MacGetFontNum() const
944 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
946 return M_FONTDATA
->m_macFontFamily
;
949 short wxFont::MacGetFontSize() const
951 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
953 return M_FONTDATA
->m_macFontSize
;
956 wxByte
wxFont::MacGetFontStyle() const
958 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
960 return M_FONTDATA
->m_macFontStyle
;
963 wxUint32
wxFont::MacGetATSUFontID() const
965 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
967 return M_FONTDATA
->m_macATSUFontID
;
970 wxUint32
wxFont::MacGetATSUAdditionalQDStyles() const
972 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
974 return M_FONTDATA
->m_macATSUAdditionalQDStyles
;
977 wxUint16
wxFont::MacGetThemeFontID() const
979 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
981 return M_FONTDATA
->m_macThemeFontID
;
985 #if wxMAC_USE_CORE_TEXT || wxMAC_USE_ATSU_TEXT
986 void * wxFont::MacGetATSUStyle() const
988 wxCHECK_MSG( M_FONTDATA
!= NULL
, NULL
, wxT("invalid font") );
990 return M_FONTDATA
->m_macATSUStyle
;
994 #if wxMAC_USE_CORE_TEXT
996 const void * wxFont::MacGetCTFont() const
998 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
1000 return (CTFontRef
)(M_FONTDATA
->m_ctFont
);
1003 const void * wxFont::MacGetCTFontDescriptor() const
1005 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
1007 return (CTFontDescriptorRef
)(M_FONTDATA
->m_ctFontDescriptor
);
1012 const wxNativeFontInfo
* wxFont::GetNativeFontInfo() const
1014 wxCHECK_MSG( M_FONTDATA
!= NULL
, NULL
, wxT("invalid font") );
1015 wxCHECK_MSG( Ok(), NULL
, wxT("invalid font") );
1017 M_FONTDATA
->m_info
.InitFromFont(*this);
1019 return &(M_FONTDATA
->m_info
);