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>
35 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
38 class WXDLLEXPORT wxFontRefData
: public wxGDIRefData
43 Init(10, wxDEFAULT
, wxNORMAL
, wxNORMAL
,
44 false, wxT("applicationfont"), wxFONTENCODING_DEFAULT
);
47 wxFontRefData(const wxFontRefData
& data
)
49 Init(data
.m_pointSize
, data
.m_family
, data
.m_style
, data
.m_weight
,
50 data
.m_underlined
, data
.m_faceName
, data
.m_encoding
);
53 wxFontRefData(int size
,
58 const wxString
& faceName
,
59 wxFontEncoding encoding
)
61 Init(size
, family
, style
, weight
, underlined
, faceName
, encoding
);
64 #if wxMAC_USE_CORE_TEXT
65 wxFontRefData( wxUint32 coreTextFontType
);
66 wxFontRefData( CTFontRef font
);
67 wxFontRefData( CTFontDescriptorRef fontdescriptor
, int size
);
70 virtual ~wxFontRefData();
72 void SetNoAntiAliasing( bool no
= true ) { m_noAA
= no
; }
74 bool GetNoAntiAliasing() const { return m_noAA
; }
76 void SetPointSize( int size
)
79 MacInvalidateNativeFont();
82 int GetPointSize() const { return m_pointSize
; }
84 void SetFamily( int family
)
87 MacInvalidateNativeFont();
91 int GetFamily() const { return m_family
; }
93 void SetStyle( int style
)
96 MacInvalidateNativeFont();
100 int GetStyle() const { return m_style
; }
102 void SetWeight( int weight
)
105 MacInvalidateNativeFont();
109 int GetWeight() const { return m_weight
; }
111 void SetUnderlined( bool u
)
114 MacInvalidateNativeFont();
117 bool GetUnderlined() const { return m_underlined
; }
119 void SetFaceName( const wxString
& facename
)
121 m_faceName
= facename
;
122 MacInvalidateNativeFont();
125 const wxString
& GetFaceName() const { return m_faceName
; }
127 void SetEncoding( wxFontEncoding encoding
)
129 m_encoding
= encoding
;
130 MacInvalidateNativeFont();
133 wxFontEncoding
GetEncoding() const { return m_encoding
; }
135 void MacInvalidateNativeFont();
140 // common part of all ctors
146 const wxString
& faceName
,
147 wxFontEncoding encoding
);
149 #if wxMAC_USE_CORE_TEXT
150 void Init( CTFontRef font
);
152 // font characterstics
159 wxFontEncoding m_encoding
;
160 bool m_noAA
; // No anti-aliasing
163 #if wxMAC_USE_ATSU_TEXT
164 FMFontFamily m_macFontFamily
;
165 FMFontSize m_macFontSize
;
166 FMFontStyle m_macFontStyle
;
168 // ATSU Font Information
170 // this is split into an ATSU font id that may
171 // contain some styles (special bold fonts etc) and
172 // these are the additional qd styles that are not
173 // included in the ATSU font id
174 ATSUFontID m_macATSUFontID
;
175 FMFontStyle m_macATSUAdditionalQDStyles
;
177 // for true themeing support we must store the correct font
178 // information here, as this speeds up and optimizes rendering
179 ThemeFontID m_macThemeFontID
;
181 #if wxMAC_USE_CORE_TEXT
182 wxCFRef
<CTFontRef
> m_ctFont
;
183 wxCFRef
<CTFontDescriptorRef
> m_ctFontDescriptor
;
185 #if wxMAC_USE_CORE_TEXT || wxMAC_USE_ATSU_TEXT
186 ATSUStyle m_macATSUStyle
;
188 wxNativeFontInfo m_info
;
191 #define M_FONTDATA ((wxFontRefData*)m_refData)
194 // ============================================================================
196 // ============================================================================
198 // ----------------------------------------------------------------------------
200 // ----------------------------------------------------------------------------
202 void wxFontRefData::Init(int pointSize
,
207 const wxString
& faceName
,
208 wxFontEncoding encoding
)
211 m_pointSize
= pointSize
;
215 m_underlined
= underlined
;
216 m_faceName
= faceName
;
217 m_encoding
= encoding
;
219 #if wxMAC_USE_ATSU_TEXT
220 m_macFontFamily
= 0 ;
224 m_macATSUAdditionalQDStyles
= 0 ;
225 m_macThemeFontID
= kThemeCurrentPortFont
;
227 #if wxMAC_USE_CORE_TEXT || wxMAC_USE_ATSU_TEXT
228 m_macATSUStyle
= NULL
;
232 wxFontRefData::~wxFontRefData()
234 #if wxMAC_USE_CORE_TEXT || wxMAC_USE_ATSU_TEXT
235 if ( m_macATSUStyle
)
237 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
238 m_macATSUStyle
= NULL
;
243 void wxFontRefData::MacInvalidateNativeFont()
245 #if wxMAC_USE_CORE_TEXT
247 m_ctFontDescriptor
.reset();
249 #if wxMAC_USE_CORE_TEXT || wxMAC_USE_ATSU_TEXT
250 if ( m_macATSUStyle
)
252 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
253 m_macATSUStyle
= NULL
;
258 #if wxMAC_USE_CORE_TEXT
260 /* from Core Text Manual Common Operations */
262 static CTFontDescriptorRef
wxMacCreateCTFontDescriptor(CFStringRef iFamilyName
, CTFontSymbolicTraits iTraits
)
264 CTFontDescriptorRef descriptor
= NULL
;
265 CFMutableDictionaryRef attributes
;
267 assert(iFamilyName
!= NULL
);
268 // Create a mutable dictionary to hold our attributes.
269 attributes
= CFDictionaryCreateMutable(kCFAllocatorDefault
, 0,
270 &kCFTypeDictionaryKeyCallBacks
, &kCFTypeDictionaryValueCallBacks
);
271 check(attributes
!= NULL
);
273 if (attributes
!= NULL
) {
274 // Add a family name to our attributes.
275 CFDictionaryAddValue(attributes
, kCTFontFamilyNameAttribute
, iFamilyName
);
279 CFMutableDictionaryRef traits
;
280 CFNumberRef symTraits
;
282 // Create the traits dictionary.
283 symTraits
= CFNumberCreate(kCFAllocatorDefault
, kCFNumberSInt32Type
,
285 check(symTraits
!= NULL
);
287 if (symTraits
!= NULL
) {
288 // Create a dictionary to hold our traits values.
289 traits
= CFDictionaryCreateMutable(kCFAllocatorDefault
, 0,
290 &kCFTypeDictionaryKeyCallBacks
, &kCFTypeDictionaryValueCallBacks
);
291 check(traits
!= NULL
);
293 if (traits
!= NULL
) {
294 // Add the symbolic traits value to the traits dictionary.
295 CFDictionaryAddValue(traits
, kCTFontSymbolicTrait
, symTraits
);
297 // Add the traits attribute to our attributes.
298 CFDictionaryAddValue(attributes
, kCTFontTraitsAttribute
, traits
);
301 CFRelease(symTraits
);
304 // Create the font descriptor with our attributes
305 descriptor
= CTFontDescriptorCreateWithAttributes(attributes
);
306 check(descriptor
!= NULL
);
308 CFRelease(attributes
);
310 // Return our font descriptor.
314 wxFontRefData::wxFontRefData( wxUint32 coreTextFontType
)
316 CTFontRef font
= CTFontCreateUIFontForLanguage( coreTextFontType
, 0.0, NULL
) ;
317 if ( CTFontGetSize(m_ctFont
) == 0 )
320 font
= CTFontCreateUIFontForLanguage( coreTextFontType
, 12.0, NULL
);
325 wxFontRefData::wxFontRefData( CTFontRef font
)
330 wxFontRefData::wxFontRefData( CTFontDescriptorRef fontdescriptor
, int size
)
334 wxCFRef
< CFNumberRef
> value( (CFNumberRef
) CTFontDescriptorCopyAttribute( fontdescriptor
, kCTFontSizeAttribute
) );
337 if ( CFNumberGetValue( value
, kCFNumberFloatType
, &fsize
) )
339 size
= (int) fsize
+ 0.5 ;
342 Init( CTFontCreateWithFontDescriptor(fontdescriptor
, size
,NULL
) );
345 void wxFontRefData::Init( CTFontRef font
)
347 Init(10, wxDEFAULT
, wxNORMAL
, wxNORMAL
,
348 false, wxT("applicationfont"), wxFONTENCODING_DEFAULT
);
350 m_ctFont
.reset( font
);
355 void wxFontRefData::MacFindFont()
358 #if wxMAC_USE_CORE_TEXT
359 if ( UMAGetSystemVersion() >= 0x1050 )
361 if ( m_faceName
.empty() && m_family
== wxDEFAULT
)
363 m_ctFont
.reset(CTFontCreateUIFontForLanguage( kCTFontSystemFontType
, 0.0, NULL
));
368 wxCFStringRef
name( CTFontCopyFamilyName( m_ctFont
) );
369 m_faceName
= name
.AsString();
370 m_pointSize
= CTFontGetSize(m_ctFont
) ;
371 CTFontSymbolicTraits traits
= CTFontGetSymbolicTraits( m_ctFont
);
372 if ( traits
& kCTFontItalicTrait
)
374 if ( traits
& kCTFontBoldTrait
)
376 if ( !m_ctFontDescriptor
.get() )
377 m_ctFontDescriptor
.reset( CTFontCopyFontDescriptor( m_ctFont
) );
381 if ( m_faceName
.empty() )
388 m_faceName
= wxT("Times");
392 m_faceName
= wxT("Lucida Grande");
397 m_faceName
= wxT("Monaco");
401 m_faceName
= wxT("Times");
407 CTFontSymbolicTraits traits
= 0;
409 if (m_weight
== wxBOLD
)
410 traits
|= kCTFontBoldTrait
;
411 if (m_style
== wxITALIC
|| m_style
== wxSLANT
)
412 traits
|= kCTFontItalicTrait
;
414 // use font descriptor caching
416 wxString lookupname
= wxString::Format( "%s_%ld", m_faceName
.c_str(), traits
);
418 static std::map
< std::wstring
, wxCFRef
< CTFontDescriptorRef
> > fontdescriptorcache
;
420 m_ctFontDescriptor
= fontdescriptorcache
[ std::wstring(lookupname
.wc_str()) ];
421 if ( !m_ctFontDescriptor
)
423 wxCFStringRef
cf( m_faceName
, wxLocale::GetSystemEncoding() );
424 m_ctFontDescriptor
.reset( wxMacCreateCTFontDescriptor( cf
, traits
) );
425 fontdescriptorcache
[ std::wstring(lookupname
.wc_str()) ] = m_ctFontDescriptor
;
428 wxCFStringRef
cf( m_faceName
, wxLocale::GetSystemEncoding() );
429 m_ctFontDescriptor
.reset( wxMacCreateCTFontDescriptor( cf
, traits
) );
434 wxString lookupnameWithSize
= wxString::Format( "%s_%ld_%ld", m_faceName
.c_str(), traits
, m_pointSize
);
436 static std::map
< std::wstring
, wxCFRef
< CTFontRef
> > fontcache
;
437 m_ctFont
= fontcache
[ std::wstring(lookupnameWithSize
.wc_str()) ];
440 m_ctFont
.reset( CTFontCreateWithFontDescriptor( m_ctFontDescriptor
, m_pointSize
, NULL
) );
441 fontcache
[ std::wstring(lookupnameWithSize
.wc_str()) ] = m_ctFont
;
444 m_ctFont
.reset( CTFontCreateWithFontDescriptor( m_ctFontDescriptor
, m_pointSize
, NULL
) );
447 #if wxMAC_USE_ATSU_TEXT == 0
448 OSStatus status
= noErr
;
449 CTFontDescriptorRef desc
= m_ctFontDescriptor
;
450 ATSFontRef atsfont
= CTFontGetPlatformFont( m_ctFont
, &desc
);
451 FMFont fmfont
= FMGetFontFromATSFontRef( atsfont
);
452 ATSUAttributeTag atsuTags
[] =
456 kATSUVerticalCharacterTag
,
459 kATSUQDUnderlineTag
,
461 ByteCount atsuSizes
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
463 sizeof( ATSUFontID
) ,
465 sizeof( ATSUVerticalCharacterType
),
470 Boolean kTrue
= true ;
471 Boolean kFalse
= false ;
473 Fixed atsuSize
= IntToFixed( m_pointSize
);
474 ATSUVerticalCharacterType kHorizontal
= kATSUStronglyHorizontal
;
475 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
480 (m_weight
== wxBOLD
) ? &kTrue
: &kFalse
,
481 (m_style
== wxITALIC
|| m_style
== wxSLANT
) ? &kTrue
: &kFalse
,
482 (m_underlined
) ? &kTrue
: &kFalse
,
485 if ( m_macATSUStyle
)
487 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
488 m_macATSUStyle
= NULL
;
490 status
= ::ATSUCreateStyle((ATSUStyle
*)&m_macATSUStyle
);
491 wxASSERT_MSG( status
== noErr
, wxT("couldn't create ATSU style") );
492 status
= ::ATSUSetAttributes(
493 (ATSUStyle
)m_macATSUStyle
,
494 sizeof(atsuTags
) / sizeof(ATSUAttributeTag
) ,
495 atsuTags
, atsuSizes
, atsuValues
);
499 #if wxMAC_USE_ATSU_TEXT
501 OSStatus status
= noErr
;
503 if ( m_macThemeFontID
!= kThemeCurrentPortFont
)
506 GetThemeFont( m_macThemeFontID
, GetApplicationScript(), qdFontName
, &m_macFontSize
, &style
);
507 if ( m_macFontSize
== 0 )
509 m_macFontStyle
= style
;
510 m_faceName
= wxMacMakeStringFromPascal( qdFontName
);
511 if ( m_macFontStyle
& bold
)
514 m_weight
= wxNORMAL
;
515 if ( m_macFontStyle
& italic
)
517 if ( m_macFontStyle
& underline
)
518 m_underlined
= true ;
519 m_pointSize
= m_macFontSize
;
520 m_macFontFamily
= FMGetFontFamilyFromName( qdFontName
);
524 if ( m_faceName
.empty() )
526 if ( m_family
== wxDEFAULT
)
528 m_macFontFamily
= GetAppFont();
529 FMGetFontFamilyName(m_macFontFamily
,qdFontName
);
530 m_faceName
= wxMacMakeStringFromPascal( qdFontName
);
539 m_faceName
= wxT("Times");
543 m_faceName
= wxT("Lucida Grande");
548 m_faceName
= wxT("Monaco");
552 m_faceName
= wxT("Times");
555 wxMacStringToPascal( m_faceName
, qdFontName
);
556 m_macFontFamily
= FMGetFontFamilyFromName( qdFontName
);
557 if ( m_macFontFamily
== kInvalidFontFamily
)
559 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for %s"), m_faceName
.c_str() );
560 m_macFontFamily
= GetAppFont();
566 if ( m_faceName
== wxT("systemfont") )
567 m_macFontFamily
= GetSysFont();
568 else if ( m_faceName
== wxT("applicationfont") )
569 m_macFontFamily
= GetAppFont();
572 wxCFStringRef
cf( m_faceName
, wxLocale::GetSystemEncoding() );
573 ATSFontFamilyRef atsfamily
= ATSFontFamilyFindFromName( cf
, kATSOptionFlagsDefault
);
574 if ( atsfamily
== (ATSFontFamilyRef
) -1 )
576 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for ") + m_faceName
);
577 m_macFontFamily
= GetAppFont();
580 m_macFontFamily
= FMGetFontFamilyFromATSFontFamilyRef( atsfamily
);
585 if (m_weight
== wxBOLD
)
586 m_macFontStyle
|= bold
;
587 if (m_style
== wxITALIC
|| m_style
== wxSLANT
)
588 m_macFontStyle
|= italic
;
590 m_macFontStyle
|= underline
;
591 m_macFontSize
= m_pointSize
;
594 // we try to get as much styles as possible into ATSU
597 // ATSUFontID and FMFont are equivalent
598 FMFontStyle intrinsicStyle
= 0 ;
599 status
= FMGetFontFromFontFamilyInstance( m_macFontFamily
, m_macFontStyle
, &m_macATSUFontID
, &intrinsicStyle
);
600 wxASSERT_MSG( status
== noErr
, wxT("couldn't get an ATSUFont from font family") );
601 m_macATSUAdditionalQDStyles
= m_macFontStyle
& (~intrinsicStyle
);
603 if ( m_macATSUStyle
)
605 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
606 m_macATSUStyle
= NULL
;
609 status
= ::ATSUCreateStyle((ATSUStyle
*)&m_macATSUStyle
);
610 wxASSERT_MSG( status
== noErr
, wxT("couldn't create ATSU style") );
612 ATSUAttributeTag atsuTags
[] =
616 kATSUVerticalCharacterTag
,
619 kATSUQDUnderlineTag
,
620 kATSUQDCondensedTag
,
623 ByteCount atsuSizes
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
625 sizeof( ATSUFontID
) ,
627 sizeof( ATSUVerticalCharacterType
),
635 Boolean kTrue
= true ;
636 Boolean kFalse
= false ;
638 Fixed atsuSize
= IntToFixed( m_macFontSize
);
639 ATSUVerticalCharacterType kHorizontal
= kATSUStronglyHorizontal
;
640 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
645 (m_macATSUAdditionalQDStyles
& bold
) ? &kTrue
: &kFalse
,
646 (m_macATSUAdditionalQDStyles
& italic
) ? &kTrue
: &kFalse
,
647 (m_macATSUAdditionalQDStyles
& underline
) ? &kTrue
: &kFalse
,
648 (m_macATSUAdditionalQDStyles
& condense
) ? &kTrue
: &kFalse
,
649 (m_macATSUAdditionalQDStyles
& extend
) ? &kTrue
: &kFalse
,
652 status
= ::ATSUSetAttributes(
653 (ATSUStyle
)m_macATSUStyle
,
654 sizeof(atsuTags
) / sizeof(ATSUAttributeTag
) ,
655 atsuTags
, atsuSizes
, atsuValues
);
657 wxASSERT_MSG( status
== noErr
, wxT("couldn't modify ATSU style") );
663 // ----------------------------------------------------------------------------
665 // ----------------------------------------------------------------------------
667 bool wxFont::Create(const wxNativeFontInfo
& info
)
670 info
.pointSize
, info
.family
, info
.style
, info
.weight
,
671 info
.underlined
, info
.faceName
, info
.encoding
);
674 wxFont::wxFont(const wxString
& fontdesc
)
676 wxNativeFontInfo info
;
677 if ( info
.FromString(fontdesc
) )
681 bool wxFont::Create(int pointSize
,
686 const wxString
& faceName
,
687 wxFontEncoding encoding
)
691 m_refData
= new wxFontRefData(
692 pointSize
, family
, style
, weight
,
693 underlined
, faceName
, encoding
);
700 #if wxMAC_USE_CORE_TEXT
702 bool wxFont::MacCreateFromUIFont(wxUint32 ctFontType
)
706 m_refData
= new wxFontRefData(ctFontType
);
712 bool wxFont::MacCreateFromCTFontDescriptor( const void * ctFontDescriptor
, int size
)
716 m_refData
= new wxFontRefData((CTFontDescriptorRef
)ctFontDescriptor
, size
);;
725 bool wxFont::MacCreateFromThemeFont(wxUint16 themeFontID
)
727 #if wxMAC_USE_CORE_TEXT
728 if ( UMAGetSystemVersion() >= 0x1050)
730 return MacCreateFromUIFont(HIThemeGetUIFontType(themeFontID
));
733 #if wxMAC_USE_ATSU_TEXT
737 m_refData
= new wxFontRefData(
738 12, wxDEFAULT
, wxFONTSTYLE_NORMAL
, wxFONTWEIGHT_NORMAL
,
739 false, wxEmptyString
, wxFONTENCODING_DEFAULT
);
741 M_FONTDATA
->m_macThemeFontID
= themeFontID
;
753 bool wxFont::RealizeResource()
755 M_FONTDATA
->MacFindFont();
760 void wxFont::SetEncoding(wxFontEncoding encoding
)
764 M_FONTDATA
->SetEncoding( encoding
);
769 void wxFont::Unshare()
771 // Don't change shared data
774 m_refData
= new wxFontRefData();
778 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
784 wxGDIRefData
*wxFont::CreateGDIRefData() const
786 return new wxFontRefData
;
789 wxGDIRefData
*wxFont::CloneGDIRefData(const wxGDIRefData
*data
) const
791 return new wxFontRefData(*wx_static_cast(const wxFontRefData
*, data
));
794 void wxFont::SetPointSize(int pointSize
)
796 if ( M_FONTDATA
->GetPointSize() == pointSize
)
801 M_FONTDATA
->SetPointSize( pointSize
);
806 void wxFont::SetFamily(int family
)
810 M_FONTDATA
->SetFamily( family
);
815 void wxFont::SetStyle(int style
)
819 M_FONTDATA
->SetStyle( style
);
824 void wxFont::SetWeight(int weight
)
828 M_FONTDATA
->SetWeight( weight
);
833 bool wxFont::SetFaceName(const wxString
& faceName
)
837 M_FONTDATA
->SetFaceName( faceName
);
841 return wxFontBase::SetFaceName(faceName
);
844 void wxFont::SetUnderlined(bool underlined
)
848 M_FONTDATA
->SetUnderlined( underlined
);
853 void wxFont::SetNoAntiAliasing( bool no
)
857 M_FONTDATA
->SetNoAntiAliasing( no
);
862 // ----------------------------------------------------------------------------
864 // ----------------------------------------------------------------------------
866 // TODO: insert checks everywhere for M_FONTDATA == NULL!
868 int wxFont::GetPointSize() const
870 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
872 return M_FONTDATA
->GetPointSize();
875 wxSize
wxFont::GetPixelSize() const
877 #if wxUSE_GRAPHICS_CONTEXT
878 // TODO: consider caching the value
879 wxGraphicsContext
* dc
= wxGraphicsContext::CreateFromNative((CGContextRef
) NULL
);
880 dc
->SetFont(*(wxFont
*)this,*wxBLACK
);
881 wxDouble width
, height
= 0;
882 dc
->GetTextExtent( wxT("g"), &width
, &height
, NULL
, NULL
);
884 return wxSize((int)width
, (int)height
);
886 return wxFontBase::GetPixelSize();
890 int wxFont::GetFamily() const
892 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
894 return M_FONTDATA
->GetFamily();
897 int wxFont::GetStyle() const
899 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
901 return M_FONTDATA
->GetStyle() ;
904 int wxFont::GetWeight() const
906 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
908 return M_FONTDATA
->GetWeight();
911 bool wxFont::GetUnderlined() const
913 wxCHECK_MSG( M_FONTDATA
!= NULL
, false, wxT("invalid font") );
915 return M_FONTDATA
->GetUnderlined();
918 wxString
wxFont::GetFaceName() const
920 wxCHECK_MSG( M_FONTDATA
!= NULL
, wxEmptyString
, wxT("invalid font") );
922 return M_FONTDATA
->GetFaceName() ;
925 wxFontEncoding
wxFont::GetEncoding() const
927 wxCHECK_MSG( M_FONTDATA
!= NULL
, wxFONTENCODING_DEFAULT
, wxT("invalid font") );
929 return M_FONTDATA
->GetEncoding() ;
932 bool wxFont::GetNoAntiAliasing() const
934 wxCHECK_MSG( M_FONTDATA
!= NULL
, false, wxT("invalid font") );
936 return M_FONTDATA
->GetNoAntiAliasing();
939 #if wxMAC_USE_ATSU_TEXT
941 short wxFont::MacGetFontNum() const
943 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
945 return M_FONTDATA
->m_macFontFamily
;
948 short wxFont::MacGetFontSize() const
950 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
952 return M_FONTDATA
->m_macFontSize
;
955 wxByte
wxFont::MacGetFontStyle() const
957 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
959 return M_FONTDATA
->m_macFontStyle
;
962 wxUint32
wxFont::MacGetATSUFontID() const
964 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
966 return M_FONTDATA
->m_macATSUFontID
;
969 wxUint32
wxFont::MacGetATSUAdditionalQDStyles() const
971 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
973 return M_FONTDATA
->m_macATSUAdditionalQDStyles
;
976 wxUint16
wxFont::MacGetThemeFontID() const
978 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
980 return M_FONTDATA
->m_macThemeFontID
;
984 #if wxMAC_USE_CORE_TEXT || wxMAC_USE_ATSU_TEXT
985 void * wxFont::MacGetATSUStyle() const
987 wxCHECK_MSG( M_FONTDATA
!= NULL
, NULL
, wxT("invalid font") );
989 return M_FONTDATA
->m_macATSUStyle
;
993 #if wxMAC_USE_CORE_TEXT
995 const void * wxFont::MacGetCTFont() const
997 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
999 return (CTFontRef
)(M_FONTDATA
->m_ctFont
);
1002 const void * wxFont::MacGetCTFontDescriptor() const
1004 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
1006 return (CTFontDescriptorRef
)(M_FONTDATA
->m_ctFontDescriptor
);
1011 const wxNativeFontInfo
* wxFont::GetNativeFontInfo() const
1013 wxCHECK_MSG( M_FONTDATA
!= NULL
, NULL
, wxT("invalid font") );
1014 wxCHECK_MSG( Ok(), NULL
, wxT("invalid font") );
1016 M_FONTDATA
->m_info
.InitFromFont(*this);
1018 return &(M_FONTDATA
->m_info
);