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"
28 #include "wx/osx/private.h"
30 #if wxOSX_USE_ATSU_TEXT && !wxOSX_USE_CARBON
31 // include themeing support
32 #include <Carbon/Carbon.h>
38 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
41 class WXDLLEXPORT wxFontRefData
: public wxGDIRefData
46 Init(10, wxDEFAULT
, wxNORMAL
, wxNORMAL
,
47 false, wxT("applicationfont"), wxFONTENCODING_DEFAULT
);
50 wxFontRefData(const wxFontRefData
& data
)
52 Init(data
.m_pointSize
, data
.m_family
, data
.m_style
, data
.m_weight
,
53 data
.m_underlined
, data
.m_faceName
, data
.m_encoding
);
56 wxFontRefData(int size
,
61 const wxString
& faceName
,
62 wxFontEncoding encoding
)
64 Init(size
, family
, style
, weight
, underlined
, faceName
, encoding
);
67 #if wxOSX_USE_CORE_TEXT
68 wxFontRefData( wxUint32 coreTextFontType
);
69 wxFontRefData( CTFontRef font
);
70 wxFontRefData( CTFontDescriptorRef fontdescriptor
, int size
);
73 virtual ~wxFontRefData();
75 void SetNoAntiAliasing( bool no
= true ) { m_noAA
= no
; }
77 bool GetNoAntiAliasing() const { return m_noAA
; }
79 void SetPointSize( int size
)
82 MacInvalidateNativeFont();
85 int GetPointSize() const { return m_pointSize
; }
87 void SetFamily( int family
)
90 MacInvalidateNativeFont();
94 int GetFamily() const { return m_family
; }
96 void SetStyle( int style
)
99 MacInvalidateNativeFont();
103 int GetStyle() const { return m_style
; }
105 void SetWeight( int weight
)
108 MacInvalidateNativeFont();
112 int GetWeight() const { return m_weight
; }
114 void SetUnderlined( bool u
)
117 MacInvalidateNativeFont();
120 bool GetUnderlined() const { return m_underlined
; }
122 void SetFaceName( const wxString
& facename
)
124 m_faceName
= facename
;
125 MacInvalidateNativeFont();
128 const wxString
& GetFaceName() const { return m_faceName
; }
130 void SetEncoding( wxFontEncoding encoding
)
132 m_encoding
= encoding
;
133 MacInvalidateNativeFont();
136 wxFontEncoding
GetEncoding() const { return m_encoding
; }
138 void MacInvalidateNativeFont();
143 // common part of all ctors
149 const wxString
& faceName
,
150 wxFontEncoding encoding
);
152 #if wxOSX_USE_CORE_TEXT
153 void Init( CTFontRef font
);
155 // font characterstics
162 wxFontEncoding m_encoding
;
163 bool m_noAA
; // No anti-aliasing
166 #if wxOSX_USE_ATSU_TEXT
167 FMFontFamily m_macFontFamily
;
168 FMFontSize m_macFontSize
;
169 FMFontStyle m_macFontStyle
;
171 // ATSU Font Information
173 // this is split into an ATSU font id that may
174 // contain some styles (special bold fonts etc) and
175 // these are the additional qd styles that are not
176 // included in the ATSU font id
177 ATSUFontID m_macATSUFontID
;
178 FMFontStyle m_macATSUAdditionalQDStyles
;
180 // for true themeing support we must store the correct font
181 // information here, as this speeds up and optimizes rendering
182 ThemeFontID m_macThemeFontID
;
184 #if wxOSX_USE_CORE_TEXT
185 wxCFRef
<CTFontRef
> m_ctFont
;
186 wxCFRef
<CTFontDescriptorRef
> m_ctFontDescriptor
;
188 #if wxOSX_USE_CORE_TEXT || wxOSX_USE_ATSU_TEXT
189 ATSUStyle m_macATSUStyle
;
191 wxNativeFontInfo m_info
;
194 #define M_FONTDATA ((wxFontRefData*)m_refData)
197 // ============================================================================
199 // ============================================================================
201 // ----------------------------------------------------------------------------
203 // ----------------------------------------------------------------------------
205 void wxFontRefData::Init(int pointSize
,
210 const wxString
& faceName
,
211 wxFontEncoding encoding
)
214 m_pointSize
= (pointSize
== -1) ? wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
).GetPointSize() : pointSize
;
218 m_underlined
= underlined
;
219 m_faceName
= faceName
;
220 m_encoding
= encoding
;
222 #if wxOSX_USE_ATSU_TEXT
223 m_macFontFamily
= 0 ;
227 m_macATSUAdditionalQDStyles
= 0 ;
228 m_macThemeFontID
= kThemeCurrentPortFont
;
230 #if wxOSX_USE_CORE_TEXT || wxOSX_USE_ATSU_TEXT
231 m_macATSUStyle
= NULL
;
235 wxFontRefData::~wxFontRefData()
237 #if wxOSX_USE_CORE_TEXT || wxOSX_USE_ATSU_TEXT
238 if ( m_macATSUStyle
)
240 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
241 m_macATSUStyle
= NULL
;
246 void wxFontRefData::MacInvalidateNativeFont()
248 #if wxOSX_USE_CORE_TEXT
250 m_ctFontDescriptor
.reset();
252 #if wxOSX_USE_CORE_TEXT || wxOSX_USE_ATSU_TEXT
253 if ( m_macATSUStyle
)
255 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
256 m_macATSUStyle
= NULL
;
261 #if wxOSX_USE_CORE_TEXT
263 /* from Core Text Manual Common Operations */
265 static CTFontDescriptorRef
wxMacCreateCTFontDescriptor(CFStringRef iFamilyName
, CTFontSymbolicTraits iTraits
)
267 CTFontDescriptorRef descriptor
= NULL
;
268 CFMutableDictionaryRef attributes
;
270 assert(iFamilyName
!= NULL
);
271 // Create a mutable dictionary to hold our attributes.
272 attributes
= CFDictionaryCreateMutable(kCFAllocatorDefault
, 0,
273 &kCFTypeDictionaryKeyCallBacks
, &kCFTypeDictionaryValueCallBacks
);
274 check(attributes
!= NULL
);
276 if (attributes
!= NULL
) {
277 // Add a family name to our attributes.
278 CFDictionaryAddValue(attributes
, kCTFontFamilyNameAttribute
, iFamilyName
);
282 CFMutableDictionaryRef traits
;
283 CFNumberRef symTraits
;
285 // Create the traits dictionary.
286 symTraits
= CFNumberCreate(kCFAllocatorDefault
, kCFNumberSInt32Type
,
288 check(symTraits
!= NULL
);
290 if (symTraits
!= NULL
) {
291 // Create a dictionary to hold our traits values.
292 traits
= CFDictionaryCreateMutable(kCFAllocatorDefault
, 0,
293 &kCFTypeDictionaryKeyCallBacks
, &kCFTypeDictionaryValueCallBacks
);
294 check(traits
!= NULL
);
296 if (traits
!= NULL
) {
297 // Add the symbolic traits value to the traits dictionary.
298 CFDictionaryAddValue(traits
, kCTFontSymbolicTrait
, symTraits
);
300 // Add the traits attribute to our attributes.
301 CFDictionaryAddValue(attributes
, kCTFontTraitsAttribute
, traits
);
304 CFRelease(symTraits
);
307 // Create the font descriptor with our attributes
308 descriptor
= CTFontDescriptorCreateWithAttributes(attributes
);
309 check(descriptor
!= NULL
);
311 CFRelease(attributes
);
313 // Return our font descriptor.
317 wxFontRefData::wxFontRefData( wxUint32 coreTextFontType
)
319 CTFontRef font
= CTFontCreateUIFontForLanguage( coreTextFontType
, 0.0, NULL
) ;
320 if ( CTFontGetSize(font
) == 0 )
323 font
= CTFontCreateUIFontForLanguage( coreTextFontType
, 12.0, NULL
);
328 wxFontRefData::wxFontRefData( CTFontRef font
)
333 wxFontRefData::wxFontRefData( CTFontDescriptorRef fontdescriptor
, int size
)
337 wxCFRef
< CFNumberRef
> value( (CFNumberRef
) CTFontDescriptorCopyAttribute( fontdescriptor
, kCTFontSizeAttribute
) );
340 if ( CFNumberGetValue( value
, kCFNumberFloatType
, &fsize
) )
342 size
= (int) fsize
+ 0.5 ;
345 Init( CTFontCreateWithFontDescriptor(fontdescriptor
, size
,NULL
) );
348 void wxFontRefData::Init( CTFontRef font
)
350 Init(10, wxDEFAULT
, wxNORMAL
, wxNORMAL
,
351 false, wxT("applicationfont"), wxFONTENCODING_DEFAULT
);
353 m_ctFont
.reset( font
);
358 void wxFontRefData::MacFindFont()
361 #if wxOSX_USE_CORE_TEXT
362 if ( UMAGetSystemVersion() >= 0x1050 )
364 if ( m_faceName
.empty() && m_family
== wxDEFAULT
)
366 m_ctFont
.reset(CTFontCreateUIFontForLanguage( kCTFontSystemFontType
, 0.0, NULL
));
371 wxCFStringRef
name( CTFontCopyFamilyName( m_ctFont
) );
372 m_faceName
= name
.AsString();
373 m_pointSize
= CTFontGetSize(m_ctFont
) ;
374 CTFontSymbolicTraits traits
= CTFontGetSymbolicTraits( m_ctFont
);
375 if ( traits
& kCTFontItalicTrait
)
377 if ( traits
& kCTFontBoldTrait
)
379 if ( !m_ctFontDescriptor
.get() )
380 m_ctFontDescriptor
.reset( CTFontCopyFontDescriptor( m_ctFont
) );
384 if ( m_faceName
.empty() )
391 m_faceName
= wxT("Times");
395 m_faceName
= wxT("Helvetica");
400 m_faceName
= wxT("Courier");
404 m_faceName
= wxT("Times");
410 CTFontSymbolicTraits traits
= 0;
412 if (m_weight
== wxBOLD
)
413 traits
|= kCTFontBoldTrait
;
414 if (m_style
== wxITALIC
|| m_style
== wxSLANT
)
415 traits
|= kCTFontItalicTrait
;
417 // use font descriptor caching
419 wxString lookupname
= wxString::Format( "%s_%ld", m_faceName
.c_str(), traits
);
421 static std::map
< std::wstring
, wxCFRef
< CTFontDescriptorRef
> > fontdescriptorcache
;
423 m_ctFontDescriptor
= fontdescriptorcache
[ std::wstring(lookupname
.wc_str()) ];
424 if ( !m_ctFontDescriptor
)
426 wxCFStringRef
cf( m_faceName
, wxLocale::GetSystemEncoding() );
427 m_ctFontDescriptor
.reset( wxMacCreateCTFontDescriptor( cf
, traits
) );
428 fontdescriptorcache
[ std::wstring(lookupname
.wc_str()) ] = m_ctFontDescriptor
;
431 wxCFStringRef
cf( m_faceName
, wxLocale::GetSystemEncoding() );
432 m_ctFontDescriptor
.reset( wxMacCreateCTFontDescriptor( cf
, traits
) );
437 wxString lookupnameWithSize
= wxString::Format( "%s_%ld_%ld", m_faceName
.c_str(), traits
, m_pointSize
);
439 static std::map
< std::wstring
, wxCFRef
< CTFontRef
> > fontcache
;
440 m_ctFont
= fontcache
[ std::wstring(lookupnameWithSize
.wc_str()) ];
443 m_ctFont
.reset( CTFontCreateWithFontDescriptor( m_ctFontDescriptor
, m_pointSize
, NULL
) );
444 fontcache
[ std::wstring(lookupnameWithSize
.wc_str()) ] = m_ctFont
;
447 m_ctFont
.reset( CTFontCreateWithFontDescriptor( m_ctFontDescriptor
, m_pointSize
, NULL
) );
449 if ( /* (CTFontGetSymbolicTraits( m_ctFont ) & 0x03) !=*/ traits
)
451 CTFontRef font
= CTFontCreateWithName( cf
, m_pointSize
, NULL
);
452 CTFontRef font2
= CTFontCreateCopyWithSymbolicTraits( font
, m_pointSize
, NULL
, traits
, 0x03 );
454 m_ctFont
.reset( font2
);
455 #if 0 // debugging coretext font matching
456 if ( (CTFontGetSymbolicTraits( m_ctFont
) & 0x03) != traits
)
458 wxMessageBox( wxString::Format( "expected %d but got %d traits" , traits
, (CTFontGetSymbolicTraits( m_ctFont
) & 0x03) ) );
463 #if wxOSX_USE_ATSU_TEXT
464 OSStatus status
= noErr
;
465 CTFontDescriptorRef desc
= m_ctFontDescriptor
;
466 ATSFontRef atsfont
= CTFontGetPlatformFont( m_ctFont
, &desc
);
467 FMFont fmfont
= FMGetFontFromATSFontRef( atsfont
);
468 ATSUAttributeTag atsuTags
[] =
472 kATSUVerticalCharacterTag
,
475 kATSUQDUnderlineTag
,
477 ByteCount atsuSizes
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
479 sizeof( ATSUFontID
) ,
481 sizeof( ATSUVerticalCharacterType
),
486 Boolean kTrue
= true ;
487 Boolean kFalse
= false ;
489 Fixed atsuSize
= IntToFixed( m_pointSize
);
490 ATSUVerticalCharacterType kHorizontal
= kATSUStronglyHorizontal
;
491 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
496 (m_weight
== wxBOLD
) ? &kTrue
: &kFalse
,
497 (m_style
== wxITALIC
|| m_style
== wxSLANT
) ? &kTrue
: &kFalse
,
498 (m_underlined
) ? &kTrue
: &kFalse
,
501 if ( m_macATSUStyle
)
503 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
504 m_macATSUStyle
= NULL
;
506 status
= ::ATSUCreateStyle((ATSUStyle
*)&m_macATSUStyle
);
507 wxASSERT_MSG( status
== noErr
, wxT("couldn't create ATSU style") );
508 status
= ::ATSUSetAttributes(
509 (ATSUStyle
)m_macATSUStyle
,
510 sizeof(atsuTags
) / sizeof(ATSUAttributeTag
) ,
511 atsuTags
, atsuSizes
, atsuValues
);
515 #if wxOSX_USE_ATSU_TEXT
517 OSStatus status
= noErr
;
519 if ( m_macThemeFontID
!= kThemeCurrentPortFont
)
522 GetThemeFont( m_macThemeFontID
, GetApplicationScript(), qdFontName
, &m_macFontSize
, &style
);
523 if ( m_macFontSize
== 0 )
525 m_macFontStyle
= style
;
526 m_faceName
= wxMacMakeStringFromPascal( qdFontName
);
527 if ( m_macFontStyle
& bold
)
530 m_weight
= wxNORMAL
;
531 if ( m_macFontStyle
& italic
)
533 if ( m_macFontStyle
& underline
)
534 m_underlined
= true ;
535 m_pointSize
= m_macFontSize
;
536 m_macFontFamily
= FMGetFontFamilyFromName( qdFontName
);
540 if ( m_faceName
.empty() )
542 if ( m_family
== wxDEFAULT
)
544 m_macFontFamily
= GetAppFont();
545 FMGetFontFamilyName(m_macFontFamily
,qdFontName
);
546 m_faceName
= wxMacMakeStringFromPascal( qdFontName
);
555 m_faceName
= wxT("Times");
559 m_faceName
= wxT("Helvetica");
564 m_faceName
= wxT("Courier");
568 m_faceName
= wxT("Times");
571 wxMacStringToPascal( m_faceName
, qdFontName
);
572 m_macFontFamily
= FMGetFontFamilyFromName( qdFontName
);
573 if ( m_macFontFamily
== kInvalidFontFamily
)
575 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for %s"), m_faceName
.c_str() );
576 m_macFontFamily
= GetAppFont();
582 if ( m_faceName
== wxT("systemfont") )
583 m_macFontFamily
= GetSysFont();
584 else if ( m_faceName
== wxT("applicationfont") )
585 m_macFontFamily
= GetAppFont();
588 wxCFStringRef
cf( m_faceName
, wxLocale::GetSystemEncoding() );
589 ATSFontFamilyRef atsfamily
= ATSFontFamilyFindFromName( cf
, kATSOptionFlagsDefault
);
590 if ( atsfamily
== (ATSFontFamilyRef
) -1 )
592 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for ") + m_faceName
);
593 m_macFontFamily
= GetAppFont();
596 m_macFontFamily
= FMGetFontFamilyFromATSFontFamilyRef( atsfamily
);
601 if (m_weight
== wxBOLD
)
602 m_macFontStyle
|= bold
;
603 if (m_style
== wxITALIC
|| m_style
== wxSLANT
)
604 m_macFontStyle
|= italic
;
606 m_macFontStyle
|= underline
;
607 m_macFontSize
= m_pointSize
;
610 // we try to get as much styles as possible into ATSU
613 // ATSUFontID and FMFont are equivalent
614 FMFontStyle intrinsicStyle
= 0 ;
615 status
= FMGetFontFromFontFamilyInstance( m_macFontFamily
, m_macFontStyle
, &m_macATSUFontID
, &intrinsicStyle
);
616 wxASSERT_MSG( status
== noErr
, wxT("couldn't get an ATSUFont from font family") );
617 m_macATSUAdditionalQDStyles
= m_macFontStyle
& (~intrinsicStyle
);
619 if ( m_macATSUStyle
)
621 ::ATSUDisposeStyle((ATSUStyle
)m_macATSUStyle
);
622 m_macATSUStyle
= NULL
;
625 status
= ::ATSUCreateStyle((ATSUStyle
*)&m_macATSUStyle
);
626 wxASSERT_MSG( status
== noErr
, wxT("couldn't create ATSU style") );
628 ATSUAttributeTag atsuTags
[] =
632 kATSUVerticalCharacterTag
,
635 kATSUQDUnderlineTag
,
636 kATSUQDCondensedTag
,
639 ByteCount atsuSizes
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
641 sizeof( ATSUFontID
) ,
643 sizeof( ATSUVerticalCharacterType
),
651 Boolean kTrue
= true ;
652 Boolean kFalse
= false ;
654 Fixed atsuSize
= IntToFixed( m_macFontSize
);
655 ATSUVerticalCharacterType kHorizontal
= kATSUStronglyHorizontal
;
656 ATSUAttributeValuePtr atsuValues
[sizeof(atsuTags
) / sizeof(ATSUAttributeTag
)] =
661 (m_macATSUAdditionalQDStyles
& bold
) ? &kTrue
: &kFalse
,
662 (m_macATSUAdditionalQDStyles
& italic
) ? &kTrue
: &kFalse
,
663 (m_macATSUAdditionalQDStyles
& underline
) ? &kTrue
: &kFalse
,
664 (m_macATSUAdditionalQDStyles
& condense
) ? &kTrue
: &kFalse
,
665 (m_macATSUAdditionalQDStyles
& extend
) ? &kTrue
: &kFalse
,
668 status
= ::ATSUSetAttributes(
669 (ATSUStyle
)m_macATSUStyle
,
670 sizeof(atsuTags
) / sizeof(ATSUAttributeTag
) ,
671 atsuTags
, atsuSizes
, atsuValues
);
673 wxASSERT_MSG( status
== noErr
, wxT("couldn't modify ATSU style") );
679 // ----------------------------------------------------------------------------
681 // ----------------------------------------------------------------------------
683 bool wxFont::Create(const wxNativeFontInfo
& info
)
686 info
.pointSize
, info
.family
, info
.style
, info
.weight
,
687 info
.underlined
, info
.faceName
, info
.encoding
);
690 wxFont::wxFont(const wxString
& fontdesc
)
692 wxNativeFontInfo info
;
693 if ( info
.FromString(fontdesc
) )
697 bool wxFont::Create(int pointSize
,
702 const wxString
& faceName
,
703 wxFontEncoding encoding
)
707 m_refData
= new wxFontRefData(
708 pointSize
, family
, style
, weight
,
709 underlined
, faceName
, encoding
);
716 #if wxOSX_USE_CORE_TEXT
718 bool wxFont::MacCreateFromUIFont(wxUint32 ctFontType
)
722 m_refData
= new wxFontRefData(ctFontType
);
728 bool wxFont::MacCreateFromCTFontDescriptor( const void * ctFontDescriptor
, int size
)
732 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
;
771 bool wxFont::RealizeResource()
773 M_FONTDATA
->MacFindFont();
778 void wxFont::SetEncoding(wxFontEncoding encoding
)
782 M_FONTDATA
->SetEncoding( encoding
);
787 void wxFont::Unshare()
789 // Don't change shared data
792 m_refData
= new wxFontRefData();
796 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
802 wxGDIRefData
*wxFont::CreateGDIRefData() const
804 return new wxFontRefData
;
807 wxGDIRefData
*wxFont::CloneGDIRefData(const wxGDIRefData
*data
) const
809 return new wxFontRefData(*wx_static_cast(const wxFontRefData
*, data
));
812 void wxFont::SetPointSize(int pointSize
)
814 if ( M_FONTDATA
->GetPointSize() == pointSize
)
819 M_FONTDATA
->SetPointSize( pointSize
);
824 void wxFont::SetFamily(int family
)
828 M_FONTDATA
->SetFamily( family
);
833 void wxFont::SetStyle(int style
)
837 M_FONTDATA
->SetStyle( style
);
842 void wxFont::SetWeight(int weight
)
846 M_FONTDATA
->SetWeight( weight
);
851 bool wxFont::SetFaceName(const wxString
& faceName
)
855 M_FONTDATA
->SetFaceName( faceName
);
859 return wxFontBase::SetFaceName(faceName
);
862 void wxFont::SetUnderlined(bool underlined
)
866 M_FONTDATA
->SetUnderlined( underlined
);
871 void wxFont::SetNoAntiAliasing( bool no
)
875 M_FONTDATA
->SetNoAntiAliasing( no
);
880 // ----------------------------------------------------------------------------
882 // ----------------------------------------------------------------------------
884 // TODO: insert checks everywhere for M_FONTDATA == NULL!
886 int wxFont::GetPointSize() const
888 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
890 return M_FONTDATA
->GetPointSize();
893 wxSize
wxFont::GetPixelSize() const
895 #if wxUSE_GRAPHICS_CONTEXT
896 // TODO: consider caching the value
897 wxGraphicsContext
* dc
= wxGraphicsContext::CreateFromNative((CGContextRef
) NULL
);
898 dc
->SetFont(*(wxFont
*)this,*wxBLACK
);
899 wxDouble width
, height
= 0;
900 dc
->GetTextExtent( wxT("g"), &width
, &height
, NULL
, NULL
);
902 return wxSize((int)width
, (int)height
);
904 return wxFontBase::GetPixelSize();
908 int wxFont::GetFamily() const
910 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
912 return M_FONTDATA
->GetFamily();
915 int wxFont::GetStyle() const
917 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
919 return M_FONTDATA
->GetStyle() ;
922 int wxFont::GetWeight() const
924 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
926 return M_FONTDATA
->GetWeight();
929 bool wxFont::GetUnderlined() const
931 wxCHECK_MSG( M_FONTDATA
!= NULL
, false, wxT("invalid font") );
933 return M_FONTDATA
->GetUnderlined();
936 wxString
wxFont::GetFaceName() const
938 wxCHECK_MSG( M_FONTDATA
!= NULL
, wxEmptyString
, wxT("invalid font") );
940 return M_FONTDATA
->GetFaceName() ;
943 wxFontEncoding
wxFont::GetEncoding() const
945 wxCHECK_MSG( M_FONTDATA
!= NULL
, wxFONTENCODING_DEFAULT
, wxT("invalid font") );
947 return M_FONTDATA
->GetEncoding() ;
950 bool wxFont::GetNoAntiAliasing() const
952 wxCHECK_MSG( M_FONTDATA
!= NULL
, false, wxT("invalid font") );
954 return M_FONTDATA
->GetNoAntiAliasing();
957 #if wxOSX_USE_ATSU_TEXT
959 short wxFont::MacGetFontNum() const
961 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
963 return M_FONTDATA
->m_macFontFamily
;
966 short wxFont::MacGetFontSize() const
968 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
970 return M_FONTDATA
->m_macFontSize
;
973 wxByte
wxFont::MacGetFontStyle() const
975 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
977 return M_FONTDATA
->m_macFontStyle
;
980 wxUint32
wxFont::MacGetATSUFontID() const
982 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
984 return M_FONTDATA
->m_macATSUFontID
;
987 wxUint32
wxFont::MacGetATSUAdditionalQDStyles() const
989 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
991 return M_FONTDATA
->m_macATSUAdditionalQDStyles
;
994 wxUint16
wxFont::MacGetThemeFontID() const
996 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
998 return M_FONTDATA
->m_macThemeFontID
;
1002 #if wxOSX_USE_CORE_TEXT || wxOSX_USE_ATSU_TEXT
1003 void * wxFont::MacGetATSUStyle() const
1005 wxCHECK_MSG( M_FONTDATA
!= NULL
, NULL
, wxT("invalid font") );
1007 return M_FONTDATA
->m_macATSUStyle
;
1011 #if wxOSX_USE_CORE_TEXT
1013 const void * wxFont::MacGetCTFont() const
1015 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
1017 return (CTFontRef
)(M_FONTDATA
->m_ctFont
);
1020 const void * wxFont::MacGetCTFontDescriptor() const
1022 wxCHECK_MSG( M_FONTDATA
!= NULL
, 0, wxT("invalid font") );
1024 return (CTFontDescriptorRef
)(M_FONTDATA
->m_ctFontDescriptor
);
1029 const wxNativeFontInfo
* wxFont::GetNativeFontInfo() const
1031 wxCHECK_MSG( M_FONTDATA
!= NULL
, NULL
, wxT("invalid font") );
1032 wxCHECK_MSG( Ok(), NULL
, wxT("invalid font") );
1034 M_FONTDATA
->m_info
.InitFromFont(*this);
1036 return &(M_FONTDATA
->m_info
);