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"
26 #include "wx/settings.h"
28 #include "wx/mac/uma.h"
31 #include <ATSUnicode.h>
37 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
40 class WXDLLEXPORT wxFontRefData
: public wxGDIRefData
45 Init(10, wxDEFAULT
, wxNORMAL
, wxNORMAL
,
46 false, wxT("applicationfont"), wxFONTENCODING_DEFAULT
);
49 wxFontRefData(const wxFontRefData
& data
)
51 Init(data
.m_pointSize
, data
.m_family
, data
.m_style
, data
.m_weight
,
52 data
.m_underlined
, data
.m_faceName
, data
.m_encoding
);
55 wxFontRefData(int size
,
60 const wxString
& faceName
,
61 wxFontEncoding encoding
)
63 Init(size
, family
, style
, weight
, underlined
, faceName
, encoding
);
66 #if wxMAC_USE_CORE_TEXT
67 wxFontRefData( wxUint32 coreTextFontType
);
68 wxFontRefData( CTFontRef font
);
69 wxFontRefData( CTFontDescriptorRef fontdescriptor
, int size
);
72 virtual ~wxFontRefData();
74 void SetNoAntiAliasing( bool no
= true ) { m_noAA
= no
; }
76 bool GetNoAntiAliasing() const { return m_noAA
; }
78 void SetPointSize( int size
)
81 MacInvalidateNativeFont();
84 int GetPointSize() const { return m_pointSize
; }
86 void SetFamily( int family
)
89 MacInvalidateNativeFont();
93 int GetFamily() const { return m_family
; }
95 void SetStyle( int style
)
98 MacInvalidateNativeFont();
102 int GetStyle() const { return m_style
; }
104 void SetWeight( int weight
)
107 MacInvalidateNativeFont();
111 int GetWeight() const { return m_weight
; }
113 void SetUnderlined( bool u
)
116 MacInvalidateNativeFont();
119 bool GetUnderlined() const { return m_underlined
; }
121 void SetFaceName( const wxString
& facename
)
123 m_faceName
= facename
;
124 MacInvalidateNativeFont();
127 const wxString
& GetFaceName() const { return m_faceName
; }
129 void SetEncoding( wxFontEncoding encoding
)
131 m_encoding
= encoding
;
132 MacInvalidateNativeFont();
135 wxFontEncoding
GetEncoding() const { return m_encoding
; }
137 void MacInvalidateNativeFont();
142 // common part of all ctors
148 const wxString
& faceName
,
149 wxFontEncoding encoding
);
151 #if wxMAC_USE_CORE_TEXT
152 void Init( CTFontRef font
);
154 // font characterstics
161 wxFontEncoding m_encoding
;
162 bool m_noAA
; // No anti-aliasing
165 #if wxMAC_USE_ATSU_TEXT
166 FMFontFamily m_macFontFamily
;
167 FMFontSize m_macFontSize
;
168 FMFontStyle m_macFontStyle
;
170 // ATSU Font Information
172 // this is split into an ATSU font id that may
173 // contain some styles (special bold fonts etc) and
174 // these are the additional qd styles that are not
175 // included in the ATSU font id
176 ATSUFontID m_macATSUFontID
;
177 FMFontStyle m_macATSUAdditionalQDStyles
;
179 // for true themeing support we must store the correct font
180 // information here, as this speeds up and optimizes rendering
181 ThemeFontID m_macThemeFontID
;
183 #if wxMAC_USE_CORE_TEXT
184 wxCFRef
<CTFontRef
> m_ctFont
;
185 wxCFRef
<CTFontDescriptorRef
> m_ctFontDescriptor
;
187 #if wxMAC_USE_CORE_TEXT || wxMAC_USE_ATSU_TEXT
188 ATSUStyle m_macATSUStyle
;
190 wxNativeFontInfo m_info
;
193 #define M_FONTDATA ((wxFontRefData*)m_refData)
196 // ============================================================================
198 // ============================================================================
200 // ----------------------------------------------------------------------------
202 // ----------------------------------------------------------------------------
204 void wxFontRefData::Init(int pointSize
,
209 const wxString
& faceName
,
210 wxFontEncoding encoding
)
213 m_pointSize
= (pointSize
== -1) ? wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
).GetPointSize() : pointSize
;
217 m_underlined
= underlined
;
218 m_faceName
= faceName
;
219 m_encoding
= encoding
;
221 #if wxMAC_USE_ATSU_TEXT
222 m_macFontFamily
= 0 ;
226 m_macATSUAdditionalQDStyles
= 0 ;
227 m_macThemeFontID
= kThemeCurrentPortFont
;
229 #if wxMAC_USE_CORE_TEXT || wxMAC_USE_ATSU_TEXT
230 m_macATSUStyle
= NULL
;
234 wxFontRefData::~wxFontRefData()
236 #if wxMAC_USE_CORE_TEXT || wxMAC_USE_ATSU_TEXT
237 if ( m_macATSUStyle
)
239 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
240 m_macATSUStyle
= NULL
;
245 void wxFontRefData::MacInvalidateNativeFont()
247 #if wxMAC_USE_CORE_TEXT
249 m_ctFontDescriptor
.reset();
251 #if wxMAC_USE_CORE_TEXT || wxMAC_USE_ATSU_TEXT
252 if ( m_macATSUStyle
)
254 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
255 m_macATSUStyle
= NULL
;
260 #if wxMAC_USE_CORE_TEXT
262 /* from Core Text Manual Common Operations */
264 static CTFontDescriptorRef
wxMacCreateCTFontDescriptor(CFStringRef iFamilyName
, CTFontSymbolicTraits iTraits
)
266 CTFontDescriptorRef descriptor
= NULL
;
267 CFMutableDictionaryRef attributes
;
269 assert(iFamilyName
!= NULL
);
270 // Create a mutable dictionary to hold our attributes.
271 attributes
= CFDictionaryCreateMutable(kCFAllocatorDefault
, 0,
272 &kCFTypeDictionaryKeyCallBacks
, &kCFTypeDictionaryValueCallBacks
);
273 check(attributes
!= NULL
);
275 if (attributes
!= NULL
) {
276 // Add a family name to our attributes.
277 CFDictionaryAddValue(attributes
, kCTFontFamilyNameAttribute
, iFamilyName
);
281 CFMutableDictionaryRef traits
;
282 CFNumberRef symTraits
;
284 // Create the traits dictionary.
285 symTraits
= CFNumberCreate(kCFAllocatorDefault
, kCFNumberSInt32Type
,
287 check(symTraits
!= NULL
);
289 if (symTraits
!= NULL
) {
290 // Create a dictionary to hold our traits values.
291 traits
= CFDictionaryCreateMutable(kCFAllocatorDefault
, 0,
292 &kCFTypeDictionaryKeyCallBacks
, &kCFTypeDictionaryValueCallBacks
);
293 check(traits
!= NULL
);
295 if (traits
!= NULL
) {
296 // Add the symbolic traits value to the traits dictionary.
297 CFDictionaryAddValue(traits
, kCTFontSymbolicTrait
, symTraits
);
299 // Add the traits attribute to our attributes.
300 CFDictionaryAddValue(attributes
, kCTFontTraitsAttribute
, traits
);
303 CFRelease(symTraits
);
306 // Create the font descriptor with our attributes
307 descriptor
= CTFontDescriptorCreateWithAttributes(attributes
);
308 check(descriptor
!= NULL
);
310 CFRelease(attributes
);
312 // Return our font descriptor.
316 wxFontRefData::wxFontRefData( wxUint32 coreTextFontType
)
318 CTFontRef font
= CTFontCreateUIFontForLanguage( coreTextFontType
, 0.0, NULL
) ;
319 if ( CTFontGetSize(m_ctFont
) == 0 )
322 font
= CTFontCreateUIFontForLanguage( coreTextFontType
, 12.0, NULL
);
327 wxFontRefData::wxFontRefData( CTFontRef font
)
332 wxFontRefData::wxFontRefData( CTFontDescriptorRef fontdescriptor
, int size
)
336 wxCFRef
< CFNumberRef
> value( (CFNumberRef
) CTFontDescriptorCopyAttribute( fontdescriptor
, kCTFontSizeAttribute
) );
339 if ( CFNumberGetValue( value
, kCFNumberFloatType
, &fsize
) )
341 size
= (int) fsize
+ 0.5 ;
344 Init( CTFontCreateWithFontDescriptor(fontdescriptor
, size
,NULL
) );
347 void wxFontRefData::Init( CTFontRef font
)
349 Init(10, wxDEFAULT
, wxNORMAL
, wxNORMAL
,
350 false, wxT("applicationfont"), wxFONTENCODING_DEFAULT
);
352 m_ctFont
.reset( font
);
357 void wxFontRefData::MacFindFont()
360 #if wxMAC_USE_CORE_TEXT
361 if ( UMAGetSystemVersion() >= 0x1050 )
363 if ( m_faceName
.empty() && m_family
== wxDEFAULT
)
365 m_ctFont
.reset(CTFontCreateUIFontForLanguage( kCTFontSystemFontType
, 0.0, NULL
));
370 wxCFStringRef
name( CTFontCopyFamilyName( m_ctFont
) );
371 m_faceName
= name
.AsString();
372 m_pointSize
= CTFontGetSize(m_ctFont
) ;
373 CTFontSymbolicTraits traits
= CTFontGetSymbolicTraits( m_ctFont
);
374 if ( traits
& kCTFontItalicTrait
)
376 if ( traits
& kCTFontBoldTrait
)
378 if ( !m_ctFontDescriptor
.get() )
379 m_ctFontDescriptor
.reset( CTFontCopyFontDescriptor( m_ctFont
) );
383 if ( m_faceName
.empty() )
390 m_faceName
= wxT("Times");
394 m_faceName
= wxT("Lucida Grande");
399 m_faceName
= wxT("Monaco");
403 m_faceName
= wxT("Times");
409 CTFontSymbolicTraits traits
= 0;
411 if (m_weight
== wxBOLD
)
412 traits
|= kCTFontBoldTrait
;
413 if (m_style
== wxITALIC
|| m_style
== wxSLANT
)
414 traits
|= kCTFontItalicTrait
;
416 // use font descriptor caching
418 wxString lookupname
= wxString::Format( "%s_%ld", m_faceName
.c_str(), traits
);
420 static std::map
< std::wstring
, wxCFRef
< CTFontDescriptorRef
> > fontdescriptorcache
;
422 m_ctFontDescriptor
= fontdescriptorcache
[ std::wstring(lookupname
.wc_str()) ];
423 if ( !m_ctFontDescriptor
)
425 wxCFStringRef
cf( m_faceName
, wxLocale::GetSystemEncoding() );
426 m_ctFontDescriptor
.reset( wxMacCreateCTFontDescriptor( cf
, traits
) );
427 fontdescriptorcache
[ std::wstring(lookupname
.wc_str()) ] = m_ctFontDescriptor
;
430 wxCFStringRef
cf( m_faceName
, wxLocale::GetSystemEncoding() );
431 m_ctFontDescriptor
.reset( wxMacCreateCTFontDescriptor( cf
, traits
) );
436 wxString lookupnameWithSize
= wxString::Format( "%s_%ld_%ld", m_faceName
.c_str(), traits
, m_pointSize
);
438 static std::map
< std::wstring
, wxCFRef
< CTFontRef
> > fontcache
;
439 m_ctFont
= fontcache
[ std::wstring(lookupnameWithSize
.wc_str()) ];
442 m_ctFont
.reset( CTFontCreateWithFontDescriptor( m_ctFontDescriptor
, m_pointSize
, NULL
) );
443 fontcache
[ std::wstring(lookupnameWithSize
.wc_str()) ] = m_ctFont
;
446 m_ctFont
.reset( CTFontCreateWithFontDescriptor( m_ctFontDescriptor
, m_pointSize
, NULL
) );
449 #if wxMAC_USE_ATSU_TEXT == 0
450 OSStatus status
= noErr
;
451 CTFontDescriptorRef desc
= m_ctFontDescriptor
;
452 ATSFontRef atsfont
= CTFontGetPlatformFont( m_ctFont
, &desc
);
453 FMFont fmfont
= FMGetFontFromATSFontRef( atsfont
);
454 ATSUAttributeTag atsuTags
[] =
458 kATSUVerticalCharacterTag
,
461 kATSUQDUnderlineTag
,
463 ByteCount atsuSizes
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
465 sizeof( ATSUFontID
) ,
467 sizeof( ATSUVerticalCharacterType
),
472 Boolean kTrue
= true ;
473 Boolean kFalse
= false ;
475 Fixed atsuSize
= IntToFixed( m_pointSize
);
476 ATSUVerticalCharacterType kHorizontal
= kATSUStronglyHorizontal
;
477 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
482 (m_weight
== wxBOLD
) ? &kTrue
: &kFalse
,
483 (m_style
== wxITALIC
|| m_style
== wxSLANT
) ? &kTrue
: &kFalse
,
484 (m_underlined
) ? &kTrue
: &kFalse
,
487 if ( m_macATSUStyle
)
489 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
490 m_macATSUStyle
= NULL
;
492 status
= ::ATSUCreateStyle((ATSUStyle
*)&m_macATSUStyle
);
493 wxASSERT_MSG( status
== noErr
, wxT("couldn't create ATSU style") );
494 status
= ::ATSUSetAttributes(
495 (ATSUStyle
)m_macATSUStyle
,
496 sizeof(atsuTags
) / sizeof(ATSUAttributeTag
) ,
497 atsuTags
, atsuSizes
, atsuValues
);
501 #if wxMAC_USE_ATSU_TEXT
503 OSStatus status
= noErr
;
505 if ( m_macThemeFontID
!= kThemeCurrentPortFont
)
508 GetThemeFont( m_macThemeFontID
, GetApplicationScript(), qdFontName
, &m_macFontSize
, &style
);
509 if ( m_macFontSize
== 0 )
511 m_macFontStyle
= style
;
512 m_faceName
= wxMacMakeStringFromPascal( qdFontName
);
513 if ( m_macFontStyle
& bold
)
516 m_weight
= wxNORMAL
;
517 if ( m_macFontStyle
& italic
)
519 if ( m_macFontStyle
& underline
)
520 m_underlined
= true ;
521 m_pointSize
= m_macFontSize
;
522 m_macFontFamily
= FMGetFontFamilyFromName( qdFontName
);
526 if ( m_faceName
.empty() )
528 if ( m_family
== wxDEFAULT
)
530 m_macFontFamily
= GetAppFont();
531 FMGetFontFamilyName(m_macFontFamily
,qdFontName
);
532 m_faceName
= wxMacMakeStringFromPascal( qdFontName
);
541 m_faceName
= wxT("Times");
545 m_faceName
= wxT("Lucida Grande");
550 m_faceName
= wxT("Monaco");
554 m_faceName
= wxT("Times");
557 wxMacStringToPascal( m_faceName
, qdFontName
);
558 m_macFontFamily
= FMGetFontFamilyFromName( qdFontName
);
559 if ( m_macFontFamily
== kInvalidFontFamily
)
561 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for %s"), m_faceName
.c_str() );
562 m_macFontFamily
= GetAppFont();
568 if ( m_faceName
== wxT("systemfont") )
569 m_macFontFamily
= GetSysFont();
570 else if ( m_faceName
== wxT("applicationfont") )
571 m_macFontFamily
= GetAppFont();
574 wxCFStringRef
cf( m_faceName
, wxLocale::GetSystemEncoding() );
575 ATSFontFamilyRef atsfamily
= ATSFontFamilyFindFromName( cf
, kATSOptionFlagsDefault
);
576 if ( atsfamily
== (ATSFontFamilyRef
) -1 )
578 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for ") + m_faceName
);
579 m_macFontFamily
= GetAppFont();
582 m_macFontFamily
= FMGetFontFamilyFromATSFontFamilyRef( atsfamily
);
587 if (m_weight
== wxBOLD
)
588 m_macFontStyle
|= bold
;
589 if (m_style
== wxITALIC
|| m_style
== wxSLANT
)
590 m_macFontStyle
|= italic
;
592 m_macFontStyle
|= underline
;
593 m_macFontSize
= m_pointSize
;
596 // we try to get as much styles as possible into ATSU
599 // ATSUFontID and FMFont are equivalent
600 FMFontStyle intrinsicStyle
= 0 ;
601 status
= FMGetFontFromFontFamilyInstance( m_macFontFamily
, m_macFontStyle
, &m_macATSUFontID
, &intrinsicStyle
);
602 wxASSERT_MSG( status
== noErr
, wxT("couldn't get an ATSUFont from font family") );
603 m_macATSUAdditionalQDStyles
= m_macFontStyle
& (~intrinsicStyle
);
605 if ( m_macATSUStyle
)
607 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
608 m_macATSUStyle
= NULL
;
611 status
= ::ATSUCreateStyle((ATSUStyle
*)&m_macATSUStyle
);
612 wxASSERT_MSG( status
== noErr
, wxT("couldn't create ATSU style") );
614 ATSUAttributeTag atsuTags
[] =
618 kATSUVerticalCharacterTag
,
621 kATSUQDUnderlineTag
,
622 kATSUQDCondensedTag
,
625 ByteCount atsuSizes
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
627 sizeof( ATSUFontID
) ,
629 sizeof( ATSUVerticalCharacterType
),
637 Boolean kTrue
= true ;
638 Boolean kFalse
= false ;
640 Fixed atsuSize
= IntToFixed( m_macFontSize
);
641 ATSUVerticalCharacterType kHorizontal
= kATSUStronglyHorizontal
;
642 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
647 (m_macATSUAdditionalQDStyles
& bold
) ? &kTrue
: &kFalse
,
648 (m_macATSUAdditionalQDStyles
& italic
) ? &kTrue
: &kFalse
,
649 (m_macATSUAdditionalQDStyles
& underline
) ? &kTrue
: &kFalse
,
650 (m_macATSUAdditionalQDStyles
& condense
) ? &kTrue
: &kFalse
,
651 (m_macATSUAdditionalQDStyles
& extend
) ? &kTrue
: &kFalse
,
654 status
= ::ATSUSetAttributes(
655 (ATSUStyle
)m_macATSUStyle
,
656 sizeof(atsuTags
) / sizeof(ATSUAttributeTag
) ,
657 atsuTags
, atsuSizes
, atsuValues
);
659 wxASSERT_MSG( status
== noErr
, wxT("couldn't modify ATSU style") );
665 // ----------------------------------------------------------------------------
667 // ----------------------------------------------------------------------------
669 bool wxFont::Create(const wxNativeFontInfo
& info
)
672 info
.pointSize
, info
.family
, info
.style
, info
.weight
,
673 info
.underlined
, info
.faceName
, info
.encoding
);
676 wxFont::wxFont(const wxString
& fontdesc
)
678 wxNativeFontInfo info
;
679 if ( info
.FromString(fontdesc
) )
683 bool wxFont::Create(int pointSize
,
688 const wxString
& faceName
,
689 wxFontEncoding encoding
)
693 m_refData
= new wxFontRefData(
694 pointSize
, family
, style
, weight
,
695 underlined
, faceName
, encoding
);
702 #if wxMAC_USE_CORE_TEXT
704 bool wxFont::MacCreateFromUIFont(wxUint32 ctFontType
)
708 m_refData
= new wxFontRefData(ctFontType
);
714 bool wxFont::MacCreateFromCTFontDescriptor( const void * ctFontDescriptor
, int size
)
718 m_refData
= new wxFontRefData((CTFontDescriptorRef
)ctFontDescriptor
, size
);;
727 bool wxFont::MacCreateFromThemeFont(wxUint16 themeFontID
)
729 #if wxMAC_USE_CORE_TEXT
730 if ( UMAGetSystemVersion() >= 0x1050)
732 return MacCreateFromUIFont(HIThemeGetUIFontType(themeFontID
));
735 #if wxMAC_USE_ATSU_TEXT
739 m_refData
= new wxFontRefData(
740 12, wxDEFAULT
, wxFONTSTYLE_NORMAL
, wxFONTWEIGHT_NORMAL
,
741 false, wxEmptyString
, wxFONTENCODING_DEFAULT
);
743 M_FONTDATA
->m_macThemeFontID
= themeFontID
;
755 bool wxFont::RealizeResource()
757 M_FONTDATA
->MacFindFont();
762 void wxFont::SetEncoding(wxFontEncoding encoding
)
766 M_FONTDATA
->SetEncoding( encoding
);
771 void wxFont::Unshare()
773 // Don't change shared data
776 m_refData
= new wxFontRefData();
780 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
786 wxGDIRefData
*wxFont::CreateGDIRefData() const
788 return new wxFontRefData
;
791 wxGDIRefData
*wxFont::CloneGDIRefData(const wxGDIRefData
*data
) const
793 return new wxFontRefData(*wx_static_cast(const wxFontRefData
*, data
));
796 void wxFont::SetPointSize(int pointSize
)
798 if ( M_FONTDATA
->GetPointSize() == pointSize
)
803 M_FONTDATA
->SetPointSize( pointSize
);
808 void wxFont::SetFamily(int family
)
812 M_FONTDATA
->SetFamily( family
);
817 void wxFont::SetStyle(int style
)
821 M_FONTDATA
->SetStyle( style
);
826 void wxFont::SetWeight(int weight
)
830 M_FONTDATA
->SetWeight( weight
);
835 bool wxFont::SetFaceName(const wxString
& faceName
)
839 M_FONTDATA
->SetFaceName( faceName
);
843 return wxFontBase::SetFaceName(faceName
);
846 void wxFont::SetUnderlined(bool underlined
)
850 M_FONTDATA
->SetUnderlined( underlined
);
855 void wxFont::SetNoAntiAliasing( bool no
)
859 M_FONTDATA
->SetNoAntiAliasing( no
);
864 // ----------------------------------------------------------------------------
866 // ----------------------------------------------------------------------------
868 // TODO: insert checks everywhere for M_FONTDATA == NULL!
870 int wxFont::GetPointSize() const
872 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
874 return M_FONTDATA
->GetPointSize();
877 wxSize
wxFont::GetPixelSize() const
879 #if wxUSE_GRAPHICS_CONTEXT
880 // TODO: consider caching the value
881 wxGraphicsContext
* dc
= wxGraphicsContext::CreateFromNative((CGContextRef
) NULL
);
882 dc
->SetFont(*(wxFont
*)this,*wxBLACK
);
883 wxDouble width
, height
= 0;
884 dc
->GetTextExtent( wxT("g"), &width
, &height
, NULL
, NULL
);
886 return wxSize((int)width
, (int)height
);
888 return wxFontBase::GetPixelSize();
892 int wxFont::GetFamily() const
894 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
896 return M_FONTDATA
->GetFamily();
899 int wxFont::GetStyle() const
901 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
903 return M_FONTDATA
->GetStyle() ;
906 int wxFont::GetWeight() const
908 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
910 return M_FONTDATA
->GetWeight();
913 bool wxFont::GetUnderlined() const
915 wxCHECK_MSG( M_FONTDATA
!= NULL
, false, wxT("invalid font") );
917 return M_FONTDATA
->GetUnderlined();
920 wxString
wxFont::GetFaceName() const
922 wxCHECK_MSG( M_FONTDATA
!= NULL
, wxEmptyString
, wxT("invalid font") );
924 return M_FONTDATA
->GetFaceName() ;
927 wxFontEncoding
wxFont::GetEncoding() const
929 wxCHECK_MSG( M_FONTDATA
!= NULL
, wxFONTENCODING_DEFAULT
, wxT("invalid font") );
931 return M_FONTDATA
->GetEncoding() ;
934 bool wxFont::GetNoAntiAliasing() const
936 wxCHECK_MSG( M_FONTDATA
!= NULL
, false, wxT("invalid font") );
938 return M_FONTDATA
->GetNoAntiAliasing();
941 #if wxMAC_USE_ATSU_TEXT
943 short wxFont::MacGetFontNum() const
945 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
947 return M_FONTDATA
->m_macFontFamily
;
950 short wxFont::MacGetFontSize() const
952 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
954 return M_FONTDATA
->m_macFontSize
;
957 wxByte
wxFont::MacGetFontStyle() const
959 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
961 return M_FONTDATA
->m_macFontStyle
;
964 wxUint32
wxFont::MacGetATSUFontID() const
966 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
968 return M_FONTDATA
->m_macATSUFontID
;
971 wxUint32
wxFont::MacGetATSUAdditionalQDStyles() const
973 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
975 return M_FONTDATA
->m_macATSUAdditionalQDStyles
;
978 wxUint16
wxFont::MacGetThemeFontID() const
980 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
982 return M_FONTDATA
->m_macThemeFontID
;
986 #if wxMAC_USE_CORE_TEXT || wxMAC_USE_ATSU_TEXT
987 void * wxFont::MacGetATSUStyle() const
989 wxCHECK_MSG( M_FONTDATA
!= NULL
, NULL
, wxT("invalid font") );
991 return M_FONTDATA
->m_macATSUStyle
;
995 #if wxMAC_USE_CORE_TEXT
997 const void * wxFont::MacGetCTFont() const
999 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
1001 return (CTFontRef
)(M_FONTDATA
->m_ctFont
);
1004 const void * wxFont::MacGetCTFontDescriptor() const
1006 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
1008 return (CTFontDescriptorRef
)(M_FONTDATA
->m_ctFontDescriptor
);
1013 const wxNativeFontInfo
* wxFont::GetNativeFontInfo() const
1015 wxCHECK_MSG( M_FONTDATA
!= NULL
, NULL
, wxT("invalid font") );
1016 wxCHECK_MSG( Ok(), NULL
, wxT("invalid font") );
1018 M_FONTDATA
->m_info
.InitFromFont(*this);
1020 return &(M_FONTDATA
->m_info
);