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"
29 #include "wx/osx/uma.h"
31 #include "wx/osx/private.h"
35 #include <ATSUnicode.h>
41 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
44 class WXDLLEXPORT wxFontRefData
: public wxGDIRefData
49 Init(10, wxDEFAULT
, wxNORMAL
, wxNORMAL
,
50 false, wxT("applicationfont"), wxFONTENCODING_DEFAULT
);
53 wxFontRefData(const wxFontRefData
& data
)
55 Init(data
.m_pointSize
, data
.m_family
, data
.m_style
, data
.m_weight
,
56 data
.m_underlined
, data
.m_faceName
, data
.m_encoding
);
59 wxFontRefData(int size
,
64 const wxString
& faceName
,
65 wxFontEncoding encoding
)
67 Init(size
, family
, style
, weight
, underlined
, faceName
, encoding
);
70 #if wxOSX_USE_CORE_TEXT
71 wxFontRefData( wxUint32 coreTextFontType
);
72 wxFontRefData( CTFontRef font
);
73 wxFontRefData( CTFontDescriptorRef fontdescriptor
, int size
);
76 virtual ~wxFontRefData();
78 void SetNoAntiAliasing( bool no
= true ) { m_noAA
= no
; }
80 bool GetNoAntiAliasing() const { return m_noAA
; }
82 void SetPointSize( int size
)
85 MacInvalidateNativeFont();
88 int GetPointSize() const { return m_pointSize
; }
90 void SetFamily( int family
)
93 MacInvalidateNativeFont();
97 int GetFamily() const { return m_family
; }
99 void SetStyle( int style
)
102 MacInvalidateNativeFont();
106 int GetStyle() const { return m_style
; }
108 void SetWeight( int weight
)
111 MacInvalidateNativeFont();
115 int GetWeight() const { return m_weight
; }
117 void SetUnderlined( bool u
)
120 MacInvalidateNativeFont();
123 bool GetUnderlined() const { return m_underlined
; }
125 void SetFaceName( const wxString
& facename
)
127 m_faceName
= facename
;
128 MacInvalidateNativeFont();
131 const wxString
& GetFaceName() const { return m_faceName
; }
133 void SetEncoding( wxFontEncoding encoding
)
135 m_encoding
= encoding
;
136 MacInvalidateNativeFont();
139 wxFontEncoding
GetEncoding() const { return m_encoding
; }
141 void MacInvalidateNativeFont();
146 // common part of all ctors
152 const wxString
& faceName
,
153 wxFontEncoding encoding
);
155 #if wxOSX_USE_CORE_TEXT
156 void Init( CTFontRef font
);
158 // font characterstics
165 wxFontEncoding m_encoding
;
166 bool m_noAA
; // No anti-aliasing
169 #if wxOSX_USE_ATSU_TEXT
170 FMFontFamily m_macFontFamily
;
171 FMFontSize m_macFontSize
;
172 FMFontStyle m_macFontStyle
;
174 // ATSU Font Information
176 // this is split into an ATSU font id that may
177 // contain some styles (special bold fonts etc) and
178 // these are the additional qd styles that are not
179 // included in the ATSU font id
180 ATSUFontID m_macATSUFontID
;
181 FMFontStyle m_macATSUAdditionalQDStyles
;
183 // for true themeing support we must store the correct font
184 // information here, as this speeds up and optimizes rendering
185 ThemeFontID m_macThemeFontID
;
187 #if wxOSX_USE_CORE_TEXT
188 wxCFRef
<CTFontRef
> m_ctFont
;
189 wxCFRef
<CTFontDescriptorRef
> m_ctFontDescriptor
;
191 #if wxOSX_USE_CORE_TEXT || wxOSX_USE_ATSU_TEXT
192 ATSUStyle m_macATSUStyle
;
194 wxNativeFontInfo m_info
;
197 #define M_FONTDATA ((wxFontRefData*)m_refData)
200 // ============================================================================
202 // ============================================================================
204 // ----------------------------------------------------------------------------
206 // ----------------------------------------------------------------------------
208 void wxFontRefData::Init(int pointSize
,
213 const wxString
& faceName
,
214 wxFontEncoding encoding
)
217 m_pointSize
= (pointSize
== -1) ? wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
).GetPointSize() : pointSize
;
221 m_underlined
= underlined
;
222 m_faceName
= faceName
;
223 m_encoding
= encoding
;
225 #if wxOSX_USE_ATSU_TEXT
226 m_macFontFamily
= 0 ;
230 m_macATSUAdditionalQDStyles
= 0 ;
231 m_macThemeFontID
= kThemeCurrentPortFont
;
233 #if wxOSX_USE_CORE_TEXT || wxOSX_USE_ATSU_TEXT
234 m_macATSUStyle
= NULL
;
238 wxFontRefData::~wxFontRefData()
240 #if wxOSX_USE_CORE_TEXT || wxOSX_USE_ATSU_TEXT
241 if ( m_macATSUStyle
)
243 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
244 m_macATSUStyle
= NULL
;
249 void wxFontRefData::MacInvalidateNativeFont()
251 #if wxOSX_USE_CORE_TEXT
253 m_ctFontDescriptor
.reset();
255 #if wxOSX_USE_CORE_TEXT || wxOSX_USE_ATSU_TEXT
256 if ( m_macATSUStyle
)
258 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
259 m_macATSUStyle
= NULL
;
264 #if wxOSX_USE_CORE_TEXT
266 /* from Core Text Manual Common Operations */
268 static CTFontDescriptorRef
wxMacCreateCTFontDescriptor(CFStringRef iFamilyName
, CTFontSymbolicTraits iTraits
)
270 CTFontDescriptorRef descriptor
= NULL
;
271 CFMutableDictionaryRef attributes
;
273 assert(iFamilyName
!= NULL
);
274 // Create a mutable dictionary to hold our attributes.
275 attributes
= CFDictionaryCreateMutable(kCFAllocatorDefault
, 0,
276 &kCFTypeDictionaryKeyCallBacks
, &kCFTypeDictionaryValueCallBacks
);
277 check(attributes
!= NULL
);
279 if (attributes
!= NULL
) {
280 // Add a family name to our attributes.
281 CFDictionaryAddValue(attributes
, kCTFontFamilyNameAttribute
, iFamilyName
);
285 CFMutableDictionaryRef traits
;
286 CFNumberRef symTraits
;
288 // Create the traits dictionary.
289 symTraits
= CFNumberCreate(kCFAllocatorDefault
, kCFNumberSInt32Type
,
291 check(symTraits
!= NULL
);
293 if (symTraits
!= NULL
) {
294 // Create a dictionary to hold our traits values.
295 traits
= CFDictionaryCreateMutable(kCFAllocatorDefault
, 0,
296 &kCFTypeDictionaryKeyCallBacks
, &kCFTypeDictionaryValueCallBacks
);
297 check(traits
!= NULL
);
299 if (traits
!= NULL
) {
300 // Add the symbolic traits value to the traits dictionary.
301 CFDictionaryAddValue(traits
, kCTFontSymbolicTrait
, symTraits
);
303 // Add the traits attribute to our attributes.
304 CFDictionaryAddValue(attributes
, kCTFontTraitsAttribute
, traits
);
307 CFRelease(symTraits
);
310 // Create the font descriptor with our attributes
311 descriptor
= CTFontDescriptorCreateWithAttributes(attributes
);
312 check(descriptor
!= NULL
);
314 CFRelease(attributes
);
316 // Return our font descriptor.
320 wxFontRefData::wxFontRefData( wxUint32 coreTextFontType
)
322 CTFontRef font
= CTFontCreateUIFontForLanguage( coreTextFontType
, 0.0, NULL
) ;
323 if ( CTFontGetSize(font
) == 0 )
326 font
= CTFontCreateUIFontForLanguage( coreTextFontType
, 12.0, NULL
);
331 wxFontRefData::wxFontRefData( CTFontRef font
)
336 wxFontRefData::wxFontRefData( CTFontDescriptorRef fontdescriptor
, int size
)
340 wxCFRef
< CFNumberRef
> value( (CFNumberRef
) CTFontDescriptorCopyAttribute( fontdescriptor
, kCTFontSizeAttribute
) );
343 if ( CFNumberGetValue( value
, kCFNumberFloatType
, &fsize
) )
345 size
= (int) fsize
+ 0.5 ;
348 Init( CTFontCreateWithFontDescriptor(fontdescriptor
, size
,NULL
) );
351 void wxFontRefData::Init( CTFontRef font
)
353 Init(10, wxDEFAULT
, wxNORMAL
, wxNORMAL
,
354 false, wxT("applicationfont"), wxFONTENCODING_DEFAULT
);
356 m_ctFont
.reset( font
);
361 void wxFontRefData::MacFindFont()
364 #if wxOSX_USE_CORE_TEXT
365 if ( UMAGetSystemVersion() >= 0x1050 )
367 if ( m_faceName
.empty() && m_family
== wxDEFAULT
)
369 m_ctFont
.reset(CTFontCreateUIFontForLanguage( kCTFontSystemFontType
, 0.0, NULL
));
374 wxCFStringRef
name( CTFontCopyFamilyName( m_ctFont
) );
375 m_faceName
= name
.AsString();
376 m_pointSize
= CTFontGetSize(m_ctFont
) ;
377 CTFontSymbolicTraits traits
= CTFontGetSymbolicTraits( m_ctFont
);
378 if ( traits
& kCTFontItalicTrait
)
380 if ( traits
& kCTFontBoldTrait
)
382 if ( !m_ctFontDescriptor
.get() )
383 m_ctFontDescriptor
.reset( CTFontCopyFontDescriptor( m_ctFont
) );
387 if ( m_faceName
.empty() )
394 m_faceName
= wxT("Times");
398 m_faceName
= wxT("Helvetica");
403 m_faceName
= wxT("Courier");
407 m_faceName
= wxT("Times");
413 CTFontSymbolicTraits traits
= 0;
415 if (m_weight
== wxBOLD
)
416 traits
|= kCTFontBoldTrait
;
417 if (m_style
== wxITALIC
|| m_style
== wxSLANT
)
418 traits
|= kCTFontItalicTrait
;
420 // use font descriptor caching
422 wxString lookupname
= wxString::Format( "%s_%ld", m_faceName
.c_str(), traits
);
424 static std::map
< std::wstring
, wxCFRef
< CTFontDescriptorRef
> > fontdescriptorcache
;
426 m_ctFontDescriptor
= fontdescriptorcache
[ std::wstring(lookupname
.wc_str()) ];
427 if ( !m_ctFontDescriptor
)
429 wxCFStringRef
cf( m_faceName
, wxLocale::GetSystemEncoding() );
430 m_ctFontDescriptor
.reset( wxMacCreateCTFontDescriptor( cf
, traits
) );
431 fontdescriptorcache
[ std::wstring(lookupname
.wc_str()) ] = m_ctFontDescriptor
;
434 wxCFStringRef
cf( m_faceName
, wxLocale::GetSystemEncoding() );
435 m_ctFontDescriptor
.reset( wxMacCreateCTFontDescriptor( cf
, traits
) );
440 wxString lookupnameWithSize
= wxString::Format( "%s_%ld_%ld", m_faceName
.c_str(), traits
, m_pointSize
);
442 static std::map
< std::wstring
, wxCFRef
< CTFontRef
> > fontcache
;
443 m_ctFont
= fontcache
[ std::wstring(lookupnameWithSize
.wc_str()) ];
446 m_ctFont
.reset( CTFontCreateWithFontDescriptor( m_ctFontDescriptor
, m_pointSize
, NULL
) );
447 fontcache
[ std::wstring(lookupnameWithSize
.wc_str()) ] = m_ctFont
;
450 m_ctFont
.reset( CTFontCreateWithFontDescriptor( m_ctFontDescriptor
, m_pointSize
, NULL
) );
452 if ( /* (CTFontGetSymbolicTraits( m_ctFont ) & 0x03) !=*/ traits
)
454 CTFontRef font
= CTFontCreateWithName( cf
, m_pointSize
, NULL
);
455 CTFontRef font2
= CTFontCreateCopyWithSymbolicTraits( font
, m_pointSize
, NULL
, traits
, 0x03 );
457 m_ctFont
.reset( font2
);
458 if ( (CTFontGetSymbolicTraits( m_ctFont
) & 0x03) != traits
)
460 wxMessageBox( wxString::Format( "expected %d but got %d traits" , traits
, (CTFontGetSymbolicTraits( m_ctFont
) & 0x03) ) );
464 #if wxOSX_USE_ATSU_TEXT
465 OSStatus status
= noErr
;
466 CTFontDescriptorRef desc
= m_ctFontDescriptor
;
467 ATSFontRef atsfont
= CTFontGetPlatformFont( m_ctFont
, &desc
);
468 FMFont fmfont
= FMGetFontFromATSFontRef( atsfont
);
469 ATSUAttributeTag atsuTags
[] =
473 kATSUVerticalCharacterTag
,
476 kATSUQDUnderlineTag
,
478 ByteCount atsuSizes
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
480 sizeof( ATSUFontID
) ,
482 sizeof( ATSUVerticalCharacterType
),
487 Boolean kTrue
= true ;
488 Boolean kFalse
= false ;
490 Fixed atsuSize
= IntToFixed( m_pointSize
);
491 ATSUVerticalCharacterType kHorizontal
= kATSUStronglyHorizontal
;
492 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
497 (m_weight
== wxBOLD
) ? &kTrue
: &kFalse
,
498 (m_style
== wxITALIC
|| m_style
== wxSLANT
) ? &kTrue
: &kFalse
,
499 (m_underlined
) ? &kTrue
: &kFalse
,
502 if ( m_macATSUStyle
)
504 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
505 m_macATSUStyle
= NULL
;
507 status
= ::ATSUCreateStyle((ATSUStyle
*)&m_macATSUStyle
);
508 wxASSERT_MSG( status
== noErr
, wxT("couldn't create ATSU style") );
509 status
= ::ATSUSetAttributes(
510 (ATSUStyle
)m_macATSUStyle
,
511 sizeof(atsuTags
) / sizeof(ATSUAttributeTag
) ,
512 atsuTags
, atsuSizes
, atsuValues
);
516 #if wxOSX_USE_ATSU_TEXT
518 OSStatus status
= noErr
;
520 if ( m_macThemeFontID
!= kThemeCurrentPortFont
)
523 GetThemeFont( m_macThemeFontID
, GetApplicationScript(), qdFontName
, &m_macFontSize
, &style
);
524 if ( m_macFontSize
== 0 )
526 m_macFontStyle
= style
;
527 m_faceName
= wxMacMakeStringFromPascal( qdFontName
);
528 if ( m_macFontStyle
& bold
)
531 m_weight
= wxNORMAL
;
532 if ( m_macFontStyle
& italic
)
534 if ( m_macFontStyle
& underline
)
535 m_underlined
= true ;
536 m_pointSize
= m_macFontSize
;
537 m_macFontFamily
= FMGetFontFamilyFromName( qdFontName
);
541 if ( m_faceName
.empty() )
543 if ( m_family
== wxDEFAULT
)
545 m_macFontFamily
= GetAppFont();
546 FMGetFontFamilyName(m_macFontFamily
,qdFontName
);
547 m_faceName
= wxMacMakeStringFromPascal( qdFontName
);
556 m_faceName
= wxT("Times");
560 m_faceName
= wxT("Helvetica");
565 m_faceName
= wxT("Courier");
569 m_faceName
= wxT("Times");
572 wxMacStringToPascal( m_faceName
, qdFontName
);
573 m_macFontFamily
= FMGetFontFamilyFromName( qdFontName
);
574 if ( m_macFontFamily
== kInvalidFontFamily
)
576 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for %s"), m_faceName
.c_str() );
577 m_macFontFamily
= GetAppFont();
583 if ( m_faceName
== wxT("systemfont") )
584 m_macFontFamily
= GetSysFont();
585 else if ( m_faceName
== wxT("applicationfont") )
586 m_macFontFamily
= GetAppFont();
589 wxCFStringRef
cf( m_faceName
, wxLocale::GetSystemEncoding() );
590 ATSFontFamilyRef atsfamily
= ATSFontFamilyFindFromName( cf
, kATSOptionFlagsDefault
);
591 if ( atsfamily
== (ATSFontFamilyRef
) -1 )
593 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for ") + m_faceName
);
594 m_macFontFamily
= GetAppFont();
597 m_macFontFamily
= FMGetFontFamilyFromATSFontFamilyRef( atsfamily
);
602 if (m_weight
== wxBOLD
)
603 m_macFontStyle
|= bold
;
604 if (m_style
== wxITALIC
|| m_style
== wxSLANT
)
605 m_macFontStyle
|= italic
;
607 m_macFontStyle
|= underline
;
608 m_macFontSize
= m_pointSize
;
611 // we try to get as much styles as possible into ATSU
614 // ATSUFontID and FMFont are equivalent
615 FMFontStyle intrinsicStyle
= 0 ;
616 status
= FMGetFontFromFontFamilyInstance( m_macFontFamily
, m_macFontStyle
, &m_macATSUFontID
, &intrinsicStyle
);
617 wxASSERT_MSG( status
== noErr
, wxT("couldn't get an ATSUFont from font family") );
618 m_macATSUAdditionalQDStyles
= m_macFontStyle
& (~intrinsicStyle
);
620 if ( m_macATSUStyle
)
622 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
623 m_macATSUStyle
= NULL
;
626 status
= ::ATSUCreateStyle((ATSUStyle
*)&m_macATSUStyle
);
627 wxASSERT_MSG( status
== noErr
, wxT("couldn't create ATSU style") );
629 ATSUAttributeTag atsuTags
[] =
633 kATSUVerticalCharacterTag
,
636 kATSUQDUnderlineTag
,
637 kATSUQDCondensedTag
,
640 ByteCount atsuSizes
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
642 sizeof( ATSUFontID
) ,
644 sizeof( ATSUVerticalCharacterType
),
652 Boolean kTrue
= true ;
653 Boolean kFalse
= false ;
655 Fixed atsuSize
= IntToFixed( m_macFontSize
);
656 ATSUVerticalCharacterType kHorizontal
= kATSUStronglyHorizontal
;
657 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
662 (m_macATSUAdditionalQDStyles
& bold
) ? &kTrue
: &kFalse
,
663 (m_macATSUAdditionalQDStyles
& italic
) ? &kTrue
: &kFalse
,
664 (m_macATSUAdditionalQDStyles
& underline
) ? &kTrue
: &kFalse
,
665 (m_macATSUAdditionalQDStyles
& condense
) ? &kTrue
: &kFalse
,
666 (m_macATSUAdditionalQDStyles
& extend
) ? &kTrue
: &kFalse
,
669 status
= ::ATSUSetAttributes(
670 (ATSUStyle
)m_macATSUStyle
,
671 sizeof(atsuTags
) / sizeof(ATSUAttributeTag
) ,
672 atsuTags
, atsuSizes
, atsuValues
);
674 wxASSERT_MSG( status
== noErr
, wxT("couldn't modify ATSU style") );
680 // ----------------------------------------------------------------------------
682 // ----------------------------------------------------------------------------
684 bool wxFont::Create(const wxNativeFontInfo
& info
)
687 info
.pointSize
, info
.family
, info
.style
, info
.weight
,
688 info
.underlined
, info
.faceName
, info
.encoding
);
691 wxFont::wxFont(const wxString
& fontdesc
)
693 wxNativeFontInfo info
;
694 if ( info
.FromString(fontdesc
) )
698 bool wxFont::Create(int pointSize
,
703 const wxString
& faceName
,
704 wxFontEncoding encoding
)
708 m_refData
= new wxFontRefData(
709 pointSize
, family
, style
, weight
,
710 underlined
, faceName
, encoding
);
717 #if wxOSX_USE_CORE_TEXT
719 bool wxFont::MacCreateFromUIFont(wxUint32 ctFontType
)
723 m_refData
= new wxFontRefData(ctFontType
);
729 bool wxFont::MacCreateFromCTFontDescriptor( const void * ctFontDescriptor
, int size
)
733 m_refData
= new wxFontRefData((CTFontDescriptorRef
)ctFontDescriptor
, size
);;
742 bool wxFont::MacCreateFromThemeFont(wxUint16 themeFontID
)
744 #if wxOSX_USE_CORE_TEXT
745 if ( UMAGetSystemVersion() >= 0x1050)
747 return MacCreateFromUIFont(HIThemeGetUIFontType(themeFontID
));
750 #if wxOSX_USE_ATSU_TEXT
754 m_refData
= new wxFontRefData(
755 12, wxDEFAULT
, wxFONTSTYLE_NORMAL
, wxFONTWEIGHT_NORMAL
,
756 false, wxEmptyString
, wxFONTENCODING_DEFAULT
);
758 M_FONTDATA
->m_macThemeFontID
= themeFontID
;
770 bool wxFont::RealizeResource()
772 M_FONTDATA
->MacFindFont();
777 void wxFont::SetEncoding(wxFontEncoding encoding
)
781 M_FONTDATA
->SetEncoding( encoding
);
786 void wxFont::Unshare()
788 // Don't change shared data
791 m_refData
= new wxFontRefData();
795 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
801 wxGDIRefData
*wxFont::CreateGDIRefData() const
803 return new wxFontRefData
;
806 wxGDIRefData
*wxFont::CloneGDIRefData(const wxGDIRefData
*data
) const
808 return new wxFontRefData(*wx_static_cast(const wxFontRefData
*, data
));
811 void wxFont::SetPointSize(int pointSize
)
813 if ( M_FONTDATA
->GetPointSize() == pointSize
)
818 M_FONTDATA
->SetPointSize( pointSize
);
823 void wxFont::SetFamily(int family
)
827 M_FONTDATA
->SetFamily( family
);
832 void wxFont::SetStyle(int style
)
836 M_FONTDATA
->SetStyle( style
);
841 void wxFont::SetWeight(int weight
)
845 M_FONTDATA
->SetWeight( weight
);
850 bool wxFont::SetFaceName(const wxString
& faceName
)
854 M_FONTDATA
->SetFaceName( faceName
);
858 return wxFontBase::SetFaceName(faceName
);
861 void wxFont::SetUnderlined(bool underlined
)
865 M_FONTDATA
->SetUnderlined( underlined
);
870 void wxFont::SetNoAntiAliasing( bool no
)
874 M_FONTDATA
->SetNoAntiAliasing( no
);
879 // ----------------------------------------------------------------------------
881 // ----------------------------------------------------------------------------
883 // TODO: insert checks everywhere for M_FONTDATA == NULL!
885 int wxFont::GetPointSize() const
887 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
889 return M_FONTDATA
->GetPointSize();
892 wxSize
wxFont::GetPixelSize() const
894 #if wxUSE_GRAPHICS_CONTEXT
895 // TODO: consider caching the value
896 wxGraphicsContext
* dc
= wxGraphicsContext::CreateFromNative((CGContextRef
) NULL
);
897 dc
->SetFont(*(wxFont
*)this,*wxBLACK
);
898 wxDouble width
, height
= 0;
899 dc
->GetTextExtent( wxT("g"), &width
, &height
, NULL
, NULL
);
901 return wxSize((int)width
, (int)height
);
903 return wxFontBase::GetPixelSize();
907 int wxFont::GetFamily() const
909 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
911 return M_FONTDATA
->GetFamily();
914 int wxFont::GetStyle() const
916 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
918 return M_FONTDATA
->GetStyle() ;
921 int wxFont::GetWeight() const
923 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
925 return M_FONTDATA
->GetWeight();
928 bool wxFont::GetUnderlined() const
930 wxCHECK_MSG( M_FONTDATA
!= NULL
, false, wxT("invalid font") );
932 return M_FONTDATA
->GetUnderlined();
935 wxString
wxFont::GetFaceName() const
937 wxCHECK_MSG( M_FONTDATA
!= NULL
, wxEmptyString
, wxT("invalid font") );
939 return M_FONTDATA
->GetFaceName() ;
942 wxFontEncoding
wxFont::GetEncoding() const
944 wxCHECK_MSG( M_FONTDATA
!= NULL
, wxFONTENCODING_DEFAULT
, wxT("invalid font") );
946 return M_FONTDATA
->GetEncoding() ;
949 bool wxFont::GetNoAntiAliasing() const
951 wxCHECK_MSG( M_FONTDATA
!= NULL
, false, wxT("invalid font") );
953 return M_FONTDATA
->GetNoAntiAliasing();
956 #if wxOSX_USE_ATSU_TEXT
958 short wxFont::MacGetFontNum() const
960 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
962 return M_FONTDATA
->m_macFontFamily
;
965 short wxFont::MacGetFontSize() const
967 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
969 return M_FONTDATA
->m_macFontSize
;
972 wxByte
wxFont::MacGetFontStyle() const
974 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
976 return M_FONTDATA
->m_macFontStyle
;
979 wxUint32
wxFont::MacGetATSUFontID() const
981 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
983 return M_FONTDATA
->m_macATSUFontID
;
986 wxUint32
wxFont::MacGetATSUAdditionalQDStyles() const
988 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
990 return M_FONTDATA
->m_macATSUAdditionalQDStyles
;
993 wxUint16
wxFont::MacGetThemeFontID() const
995 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
997 return M_FONTDATA
->m_macThemeFontID
;
1001 #if wxOSX_USE_CORE_TEXT || wxOSX_USE_ATSU_TEXT
1002 void * wxFont::MacGetATSUStyle() const
1004 wxCHECK_MSG( M_FONTDATA
!= NULL
, NULL
, wxT("invalid font") );
1006 return M_FONTDATA
->m_macATSUStyle
;
1010 #if wxOSX_USE_CORE_TEXT
1012 const void * wxFont::MacGetCTFont() const
1014 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
1016 return (CTFontRef
)(M_FONTDATA
->m_ctFont
);
1019 const void * wxFont::MacGetCTFontDescriptor() const
1021 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
1023 return (CTFontDescriptorRef
)(M_FONTDATA
->m_ctFontDescriptor
);
1028 const wxNativeFontInfo
* wxFont::GetNativeFontInfo() const
1030 wxCHECK_MSG( M_FONTDATA
!= NULL
, NULL
, wxT("invalid font") );
1031 wxCHECK_MSG( Ok(), NULL
, wxT("invalid font") );
1033 M_FONTDATA
->m_info
.InitFromFont(*this);
1035 return &(M_FONTDATA
->m_info
);