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 0 // debugging coretext font matching
455 if ( (CTFontGetSymbolicTraits( m_ctFont
) & 0x03) != traits
)
457 wxMessageBox( wxString::Format( "expected %d but got %d traits" , traits
, (CTFontGetSymbolicTraits( m_ctFont
) & 0x03) ) );
462 #if wxOSX_USE_ATSU_TEXT
463 OSStatus status
= noErr
;
464 CTFontDescriptorRef desc
= m_ctFontDescriptor
;
465 ATSFontRef atsfont
= CTFontGetPlatformFont( m_ctFont
, &desc
);
466 FMFont fmfont
= FMGetFontFromATSFontRef( atsfont
);
467 ATSUAttributeTag atsuTags
[] =
471 kATSUVerticalCharacterTag
,
474 kATSUQDUnderlineTag
,
476 ByteCount atsuSizes
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
478 sizeof( ATSUFontID
) ,
480 sizeof( ATSUVerticalCharacterType
),
485 Boolean kTrue
= true ;
486 Boolean kFalse
= false ;
488 Fixed atsuSize
= IntToFixed( m_pointSize
);
489 ATSUVerticalCharacterType kHorizontal
= kATSUStronglyHorizontal
;
490 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
495 (m_weight
== wxBOLD
) ? &kTrue
: &kFalse
,
496 (m_style
== wxITALIC
|| m_style
== wxSLANT
) ? &kTrue
: &kFalse
,
497 (m_underlined
) ? &kTrue
: &kFalse
,
500 if ( m_macATSUStyle
)
502 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
503 m_macATSUStyle
= NULL
;
505 status
= ::ATSUCreateStyle((ATSUStyle
*)&m_macATSUStyle
);
506 wxASSERT_MSG( status
== noErr
, wxT("couldn't create ATSU style") );
507 status
= ::ATSUSetAttributes(
508 (ATSUStyle
)m_macATSUStyle
,
509 sizeof(atsuTags
) / sizeof(ATSUAttributeTag
) ,
510 atsuTags
, atsuSizes
, atsuValues
);
514 #if wxOSX_USE_ATSU_TEXT
516 OSStatus status
= noErr
;
518 if ( m_macThemeFontID
!= kThemeCurrentPortFont
)
521 GetThemeFont( m_macThemeFontID
, GetApplicationScript(), qdFontName
, &m_macFontSize
, &style
);
522 if ( m_macFontSize
== 0 )
524 m_macFontStyle
= style
;
525 m_faceName
= wxMacMakeStringFromPascal( qdFontName
);
526 if ( m_macFontStyle
& bold
)
529 m_weight
= wxNORMAL
;
530 if ( m_macFontStyle
& italic
)
532 if ( m_macFontStyle
& underline
)
533 m_underlined
= true ;
534 m_pointSize
= m_macFontSize
;
535 m_macFontFamily
= FMGetFontFamilyFromName( qdFontName
);
539 if ( m_faceName
.empty() )
541 if ( m_family
== wxDEFAULT
)
543 m_macFontFamily
= GetAppFont();
544 FMGetFontFamilyName(m_macFontFamily
,qdFontName
);
545 m_faceName
= wxMacMakeStringFromPascal( qdFontName
);
554 m_faceName
= wxT("Times");
558 m_faceName
= wxT("Helvetica");
563 m_faceName
= wxT("Courier");
567 m_faceName
= wxT("Times");
570 wxMacStringToPascal( m_faceName
, qdFontName
);
571 m_macFontFamily
= FMGetFontFamilyFromName( qdFontName
);
572 if ( m_macFontFamily
== kInvalidFontFamily
)
574 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for %s"), m_faceName
.c_str() );
575 m_macFontFamily
= GetAppFont();
581 if ( m_faceName
== wxT("systemfont") )
582 m_macFontFamily
= GetSysFont();
583 else if ( m_faceName
== wxT("applicationfont") )
584 m_macFontFamily
= GetAppFont();
587 wxCFStringRef
cf( m_faceName
, wxLocale::GetSystemEncoding() );
588 ATSFontFamilyRef atsfamily
= ATSFontFamilyFindFromName( cf
, kATSOptionFlagsDefault
);
589 if ( atsfamily
== (ATSFontFamilyRef
) -1 )
591 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for ") + m_faceName
);
592 m_macFontFamily
= GetAppFont();
595 m_macFontFamily
= FMGetFontFamilyFromATSFontFamilyRef( atsfamily
);
600 if (m_weight
== wxBOLD
)
601 m_macFontStyle
|= bold
;
602 if (m_style
== wxITALIC
|| m_style
== wxSLANT
)
603 m_macFontStyle
|= italic
;
605 m_macFontStyle
|= underline
;
606 m_macFontSize
= m_pointSize
;
609 // we try to get as much styles as possible into ATSU
612 // ATSUFontID and FMFont are equivalent
613 FMFontStyle intrinsicStyle
= 0 ;
614 status
= FMGetFontFromFontFamilyInstance( m_macFontFamily
, m_macFontStyle
, &m_macATSUFontID
, &intrinsicStyle
);
615 wxASSERT_MSG( status
== noErr
, wxT("couldn't get an ATSUFont from font family") );
616 m_macATSUAdditionalQDStyles
= m_macFontStyle
& (~intrinsicStyle
);
618 if ( m_macATSUStyle
)
620 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
621 m_macATSUStyle
= NULL
;
624 status
= ::ATSUCreateStyle((ATSUStyle
*)&m_macATSUStyle
);
625 wxASSERT_MSG( status
== noErr
, wxT("couldn't create ATSU style") );
627 ATSUAttributeTag atsuTags
[] =
631 kATSUVerticalCharacterTag
,
634 kATSUQDUnderlineTag
,
635 kATSUQDCondensedTag
,
638 ByteCount atsuSizes
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
640 sizeof( ATSUFontID
) ,
642 sizeof( ATSUVerticalCharacterType
),
650 Boolean kTrue
= true ;
651 Boolean kFalse
= false ;
653 Fixed atsuSize
= IntToFixed( m_macFontSize
);
654 ATSUVerticalCharacterType kHorizontal
= kATSUStronglyHorizontal
;
655 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
660 (m_macATSUAdditionalQDStyles
& bold
) ? &kTrue
: &kFalse
,
661 (m_macATSUAdditionalQDStyles
& italic
) ? &kTrue
: &kFalse
,
662 (m_macATSUAdditionalQDStyles
& underline
) ? &kTrue
: &kFalse
,
663 (m_macATSUAdditionalQDStyles
& condense
) ? &kTrue
: &kFalse
,
664 (m_macATSUAdditionalQDStyles
& extend
) ? &kTrue
: &kFalse
,
667 status
= ::ATSUSetAttributes(
668 (ATSUStyle
)m_macATSUStyle
,
669 sizeof(atsuTags
) / sizeof(ATSUAttributeTag
) ,
670 atsuTags
, atsuSizes
, atsuValues
);
672 wxASSERT_MSG( status
== noErr
, wxT("couldn't modify ATSU style") );
678 // ----------------------------------------------------------------------------
680 // ----------------------------------------------------------------------------
682 bool wxFont::Create(const wxNativeFontInfo
& info
)
685 info
.pointSize
, info
.family
, info
.style
, info
.weight
,
686 info
.underlined
, info
.faceName
, info
.encoding
);
689 wxFont::wxFont(const wxString
& fontdesc
)
691 wxNativeFontInfo info
;
692 if ( info
.FromString(fontdesc
) )
696 bool wxFont::Create(int pointSize
,
701 const wxString
& faceName
,
702 wxFontEncoding encoding
)
706 m_refData
= new wxFontRefData(
707 pointSize
, family
, style
, weight
,
708 underlined
, faceName
, encoding
);
715 #if wxOSX_USE_CORE_TEXT
717 bool wxFont::MacCreateFromUIFont(wxUint32 ctFontType
)
721 m_refData
= new wxFontRefData(ctFontType
);
727 bool wxFont::MacCreateFromCTFontDescriptor( const void * ctFontDescriptor
, int size
)
731 m_refData
= new wxFontRefData((CTFontDescriptorRef
)ctFontDescriptor
, size
);;
741 bool wxFont::MacCreateFromThemeFont(wxUint16 themeFontID
)
743 #if wxOSX_USE_CORE_TEXT
744 if ( UMAGetSystemVersion() >= 0x1050)
746 return MacCreateFromUIFont(HIThemeGetUIFontType(themeFontID
));
749 #if wxOSX_USE_ATSU_TEXT
753 m_refData
= new wxFontRefData(
754 12, wxDEFAULT
, wxFONTSTYLE_NORMAL
, wxFONTWEIGHT_NORMAL
,
755 false, wxEmptyString
, wxFONTENCODING_DEFAULT
);
757 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
);