1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/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"
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 wxOSX_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 wxOSX_USE_CORE_TEXT
152 void Init( CTFontRef font
);
154 // font characterstics
161 wxFontEncoding m_encoding
;
162 bool m_noAA
; // No anti-aliasing
165 #if wxOSX_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 wxOSX_USE_CORE_TEXT
184 wxCFRef
<CTFontRef
> m_ctFont
;
185 wxCFRef
<CTFontDescriptorRef
> m_ctFontDescriptor
;
187 #if wxOSX_USE_CORE_TEXT || wxOSX_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 wxOSX_USE_ATSU_TEXT
222 m_macFontFamily
= 0 ;
226 m_macATSUAdditionalQDStyles
= 0 ;
227 m_macThemeFontID
= kThemeCurrentPortFont
;
229 #if wxOSX_USE_CORE_TEXT || wxOSX_USE_ATSU_TEXT
230 m_macATSUStyle
= NULL
;
234 wxFontRefData::~wxFontRefData()
236 #if wxOSX_USE_CORE_TEXT || wxOSX_USE_ATSU_TEXT
237 if ( m_macATSUStyle
)
239 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
240 m_macATSUStyle
= NULL
;
245 void wxFontRefData::MacInvalidateNativeFont()
247 #if wxOSX_USE_CORE_TEXT
249 m_ctFontDescriptor
.reset();
251 #if wxOSX_USE_CORE_TEXT || wxOSX_USE_ATSU_TEXT
252 if ( m_macATSUStyle
)
254 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
255 m_macATSUStyle
= NULL
;
260 #if wxOSX_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(font
) == 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 wxOSX_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("Helvetica");
399 m_faceName
= wxT("Courier");
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
) );
448 if ( /* (CTFontGetSymbolicTraits( m_ctFont ) & 0x03) !=*/ traits
)
450 CTFontRef font
= CTFontCreateWithName( cf
, m_pointSize
, NULL
);
451 CTFontRef font2
= CTFontCreateCopyWithSymbolicTraits( font
, m_pointSize
, NULL
, traits
, 0x03 );
453 m_ctFont
.reset( font2
);
454 if ( (CTFontGetSymbolicTraits( m_ctFont
) & 0x03) != traits
)
456 wxMessageBox( wxString::Format( "expected %d but got %d traits" , traits
, (CTFontGetSymbolicTraits( m_ctFont
) & 0x03) ) );
460 #if wxOSX_USE_ATSU_TEXT
461 OSStatus status
= noErr
;
462 CTFontDescriptorRef desc
= m_ctFontDescriptor
;
463 ATSFontRef atsfont
= CTFontGetPlatformFont( m_ctFont
, &desc
);
464 FMFont fmfont
= FMGetFontFromATSFontRef( atsfont
);
465 ATSUAttributeTag atsuTags
[] =
469 kATSUVerticalCharacterTag
,
472 kATSUQDUnderlineTag
,
474 ByteCount atsuSizes
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
476 sizeof( ATSUFontID
) ,
478 sizeof( ATSUVerticalCharacterType
),
483 Boolean kTrue
= true ;
484 Boolean kFalse
= false ;
486 Fixed atsuSize
= IntToFixed( m_pointSize
);
487 ATSUVerticalCharacterType kHorizontal
= kATSUStronglyHorizontal
;
488 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
493 (m_weight
== wxBOLD
) ? &kTrue
: &kFalse
,
494 (m_style
== wxITALIC
|| m_style
== wxSLANT
) ? &kTrue
: &kFalse
,
495 (m_underlined
) ? &kTrue
: &kFalse
,
498 if ( m_macATSUStyle
)
500 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
501 m_macATSUStyle
= NULL
;
503 status
= ::ATSUCreateStyle((ATSUStyle
*)&m_macATSUStyle
);
504 wxASSERT_MSG( status
== noErr
, wxT("couldn't create ATSU style") );
505 status
= ::ATSUSetAttributes(
506 (ATSUStyle
)m_macATSUStyle
,
507 sizeof(atsuTags
) / sizeof(ATSUAttributeTag
) ,
508 atsuTags
, atsuSizes
, atsuValues
);
512 #if wxOSX_USE_ATSU_TEXT
514 OSStatus status
= noErr
;
516 if ( m_macThemeFontID
!= kThemeCurrentPortFont
)
519 GetThemeFont( m_macThemeFontID
, GetApplicationScript(), qdFontName
, &m_macFontSize
, &style
);
520 if ( m_macFontSize
== 0 )
522 m_macFontStyle
= style
;
523 m_faceName
= wxMacMakeStringFromPascal( qdFontName
);
524 if ( m_macFontStyle
& bold
)
527 m_weight
= wxNORMAL
;
528 if ( m_macFontStyle
& italic
)
530 if ( m_macFontStyle
& underline
)
531 m_underlined
= true ;
532 m_pointSize
= m_macFontSize
;
533 m_macFontFamily
= FMGetFontFamilyFromName( qdFontName
);
537 if ( m_faceName
.empty() )
539 if ( m_family
== wxDEFAULT
)
541 m_macFontFamily
= GetAppFont();
542 FMGetFontFamilyName(m_macFontFamily
,qdFontName
);
543 m_faceName
= wxMacMakeStringFromPascal( qdFontName
);
552 m_faceName
= wxT("Times");
556 m_faceName
= wxT("Helvetica");
561 m_faceName
= wxT("Courier");
565 m_faceName
= wxT("Times");
568 wxMacStringToPascal( m_faceName
, qdFontName
);
569 m_macFontFamily
= FMGetFontFamilyFromName( qdFontName
);
570 if ( m_macFontFamily
== kInvalidFontFamily
)
572 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for %s"), m_faceName
.c_str() );
573 m_macFontFamily
= GetAppFont();
579 if ( m_faceName
== wxT("systemfont") )
580 m_macFontFamily
= GetSysFont();
581 else if ( m_faceName
== wxT("applicationfont") )
582 m_macFontFamily
= GetAppFont();
585 wxCFStringRef
cf( m_faceName
, wxLocale::GetSystemEncoding() );
586 ATSFontFamilyRef atsfamily
= ATSFontFamilyFindFromName( cf
, kATSOptionFlagsDefault
);
587 if ( atsfamily
== (ATSFontFamilyRef
) -1 )
589 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for ") + m_faceName
);
590 m_macFontFamily
= GetAppFont();
593 m_macFontFamily
= FMGetFontFamilyFromATSFontFamilyRef( atsfamily
);
598 if (m_weight
== wxBOLD
)
599 m_macFontStyle
|= bold
;
600 if (m_style
== wxITALIC
|| m_style
== wxSLANT
)
601 m_macFontStyle
|= italic
;
603 m_macFontStyle
|= underline
;
604 m_macFontSize
= m_pointSize
;
607 // we try to get as much styles as possible into ATSU
610 // ATSUFontID and FMFont are equivalent
611 FMFontStyle intrinsicStyle
= 0 ;
612 status
= FMGetFontFromFontFamilyInstance( m_macFontFamily
, m_macFontStyle
, &m_macATSUFontID
, &intrinsicStyle
);
613 wxASSERT_MSG( status
== noErr
, wxT("couldn't get an ATSUFont from font family") );
614 m_macATSUAdditionalQDStyles
= m_macFontStyle
& (~intrinsicStyle
);
616 if ( m_macATSUStyle
)
618 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
619 m_macATSUStyle
= NULL
;
622 status
= ::ATSUCreateStyle((ATSUStyle
*)&m_macATSUStyle
);
623 wxASSERT_MSG( status
== noErr
, wxT("couldn't create ATSU style") );
625 ATSUAttributeTag atsuTags
[] =
629 kATSUVerticalCharacterTag
,
632 kATSUQDUnderlineTag
,
633 kATSUQDCondensedTag
,
636 ByteCount atsuSizes
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
638 sizeof( ATSUFontID
) ,
640 sizeof( ATSUVerticalCharacterType
),
648 Boolean kTrue
= true ;
649 Boolean kFalse
= false ;
651 Fixed atsuSize
= IntToFixed( m_macFontSize
);
652 ATSUVerticalCharacterType kHorizontal
= kATSUStronglyHorizontal
;
653 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
658 (m_macATSUAdditionalQDStyles
& bold
) ? &kTrue
: &kFalse
,
659 (m_macATSUAdditionalQDStyles
& italic
) ? &kTrue
: &kFalse
,
660 (m_macATSUAdditionalQDStyles
& underline
) ? &kTrue
: &kFalse
,
661 (m_macATSUAdditionalQDStyles
& condense
) ? &kTrue
: &kFalse
,
662 (m_macATSUAdditionalQDStyles
& extend
) ? &kTrue
: &kFalse
,
665 status
= ::ATSUSetAttributes(
666 (ATSUStyle
)m_macATSUStyle
,
667 sizeof(atsuTags
) / sizeof(ATSUAttributeTag
) ,
668 atsuTags
, atsuSizes
, atsuValues
);
670 wxASSERT_MSG( status
== noErr
, wxT("couldn't modify ATSU style") );
676 // ----------------------------------------------------------------------------
678 // ----------------------------------------------------------------------------
680 bool wxFont::Create(const wxNativeFontInfo
& info
)
683 info
.pointSize
, info
.family
, info
.style
, info
.weight
,
684 info
.underlined
, info
.faceName
, info
.encoding
);
687 wxFont::wxFont(const wxString
& fontdesc
)
689 wxNativeFontInfo info
;
690 if ( info
.FromString(fontdesc
) )
694 bool wxFont::Create(int pointSize
,
699 const wxString
& faceName
,
700 wxFontEncoding encoding
)
704 m_refData
= new wxFontRefData(
705 pointSize
, family
, style
, weight
,
706 underlined
, faceName
, encoding
);
713 #if wxOSX_USE_CORE_TEXT
715 bool wxFont::MacCreateFromUIFont(wxUint32 ctFontType
)
719 m_refData
= new wxFontRefData(ctFontType
);
725 bool wxFont::MacCreateFromCTFontDescriptor( const void * ctFontDescriptor
, int size
)
729 m_refData
= new wxFontRefData((CTFontDescriptorRef
)ctFontDescriptor
, size
);;
739 bool wxFont::MacCreateFromThemeFont(wxUint16 themeFontID
)
741 #if wxOSX_USE_CORE_TEXT
742 if ( UMAGetSystemVersion() >= 0x1050)
744 return MacCreateFromUIFont(HIThemeGetUIFontType(themeFontID
));
747 #if wxOSX_USE_ATSU_TEXT
751 m_refData
= new wxFontRefData(
752 12, wxDEFAULT
, wxFONTSTYLE_NORMAL
, wxFONTWEIGHT_NORMAL
,
753 false, wxEmptyString
, wxFONTENCODING_DEFAULT
);
755 M_FONTDATA
->m_macThemeFontID
= themeFontID
;
768 bool wxFont::RealizeResource()
770 M_FONTDATA
->MacFindFont();
775 void wxFont::SetEncoding(wxFontEncoding encoding
)
779 M_FONTDATA
->SetEncoding( encoding
);
784 void wxFont::Unshare()
786 // Don't change shared data
789 m_refData
= new wxFontRefData();
793 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
799 wxGDIRefData
*wxFont::CreateGDIRefData() const
801 return new wxFontRefData
;
804 wxGDIRefData
*wxFont::CloneGDIRefData(const wxGDIRefData
*data
) const
806 return new wxFontRefData(*wx_static_cast(const wxFontRefData
*, data
));
809 void wxFont::SetPointSize(int pointSize
)
811 if ( M_FONTDATA
->GetPointSize() == pointSize
)
816 M_FONTDATA
->SetPointSize( pointSize
);
821 void wxFont::SetFamily(int family
)
825 M_FONTDATA
->SetFamily( family
);
830 void wxFont::SetStyle(int style
)
834 M_FONTDATA
->SetStyle( style
);
839 void wxFont::SetWeight(int weight
)
843 M_FONTDATA
->SetWeight( weight
);
848 bool wxFont::SetFaceName(const wxString
& faceName
)
852 M_FONTDATA
->SetFaceName( faceName
);
856 return wxFontBase::SetFaceName(faceName
);
859 void wxFont::SetUnderlined(bool underlined
)
863 M_FONTDATA
->SetUnderlined( underlined
);
868 void wxFont::SetNoAntiAliasing( bool no
)
872 M_FONTDATA
->SetNoAntiAliasing( no
);
877 // ----------------------------------------------------------------------------
879 // ----------------------------------------------------------------------------
881 // TODO: insert checks everywhere for M_FONTDATA == NULL!
883 int wxFont::GetPointSize() const
885 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
887 return M_FONTDATA
->GetPointSize();
890 wxSize
wxFont::GetPixelSize() const
892 #if wxUSE_GRAPHICS_CONTEXT
893 // TODO: consider caching the value
894 wxGraphicsContext
* dc
= wxGraphicsContext::CreateFromNative((CGContextRef
) NULL
);
895 dc
->SetFont(*(wxFont
*)this,*wxBLACK
);
896 wxDouble width
, height
= 0;
897 dc
->GetTextExtent( wxT("g"), &width
, &height
, NULL
, NULL
);
899 return wxSize((int)width
, (int)height
);
901 return wxFontBase::GetPixelSize();
905 int wxFont::GetFamily() const
907 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
909 return M_FONTDATA
->GetFamily();
912 int wxFont::GetStyle() const
914 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
916 return M_FONTDATA
->GetStyle() ;
919 int wxFont::GetWeight() const
921 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
923 return M_FONTDATA
->GetWeight();
926 bool wxFont::GetUnderlined() const
928 wxCHECK_MSG( M_FONTDATA
!= NULL
, false, wxT("invalid font") );
930 return M_FONTDATA
->GetUnderlined();
933 wxString
wxFont::GetFaceName() const
935 wxCHECK_MSG( M_FONTDATA
!= NULL
, wxEmptyString
, wxT("invalid font") );
937 return M_FONTDATA
->GetFaceName() ;
940 wxFontEncoding
wxFont::GetEncoding() const
942 wxCHECK_MSG( M_FONTDATA
!= NULL
, wxFONTENCODING_DEFAULT
, wxT("invalid font") );
944 return M_FONTDATA
->GetEncoding() ;
947 bool wxFont::GetNoAntiAliasing() const
949 wxCHECK_MSG( M_FONTDATA
!= NULL
, false, wxT("invalid font") );
951 return M_FONTDATA
->GetNoAntiAliasing();
954 #if wxOSX_USE_ATSU_TEXT
956 short wxFont::MacGetFontNum() const
958 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
960 return M_FONTDATA
->m_macFontFamily
;
963 short wxFont::MacGetFontSize() const
965 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
967 return M_FONTDATA
->m_macFontSize
;
970 wxByte
wxFont::MacGetFontStyle() const
972 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
974 return M_FONTDATA
->m_macFontStyle
;
977 wxUint32
wxFont::MacGetATSUFontID() const
979 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
981 return M_FONTDATA
->m_macATSUFontID
;
984 wxUint32
wxFont::MacGetATSUAdditionalQDStyles() const
986 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
988 return M_FONTDATA
->m_macATSUAdditionalQDStyles
;
991 wxUint16
wxFont::MacGetThemeFontID() const
993 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
995 return M_FONTDATA
->m_macThemeFontID
;
999 #if wxOSX_USE_CORE_TEXT || wxOSX_USE_ATSU_TEXT
1000 void * wxFont::MacGetATSUStyle() const
1002 wxCHECK_MSG( M_FONTDATA
!= NULL
, NULL
, wxT("invalid font") );
1004 return M_FONTDATA
->m_macATSUStyle
;
1008 #if wxOSX_USE_CORE_TEXT
1010 const void * wxFont::MacGetCTFont() const
1012 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
1014 return (CTFontRef
)(M_FONTDATA
->m_ctFont
);
1017 const void * wxFont::MacGetCTFontDescriptor() const
1019 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
1021 return (CTFontDescriptorRef
)(M_FONTDATA
->m_ctFontDescriptor
);
1026 const wxNativeFontInfo
* wxFont::GetNativeFontInfo() const
1028 wxCHECK_MSG( M_FONTDATA
!= NULL
, NULL
, wxT("invalid font") );
1029 wxCHECK_MSG( Ok(), NULL
, wxT("invalid font") );
1031 M_FONTDATA
->m_info
.InitFromFont(*this);
1033 return &(M_FONTDATA
->m_info
);