]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/font.cpp
241ae9a01933ae28910f9e0a004b9eac3d6fab04
[wxWidgets.git] / src / mac / carbon / font.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/font.cpp
3 // Purpose: wxFont class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #include "wx/font.h"
15
16 #ifndef WX_PRECOMP
17 #include "wx/string.h"
18 #include "wx/utils.h"
19 #include "wx/intl.h"
20 #include "wx/gdicmn.h"
21 #include "wx/log.h"
22 #endif
23
24 #include "wx/fontutil.h"
25 #include "wx/graphics.h"
26
27 #include "wx/mac/uma.h"
28
29 #ifndef __DARWIN__
30 #include <ATSUnicode.h>
31 #endif
32
33
34 IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
35
36
37 class WXDLLEXPORT wxFontRefData: public wxGDIRefData
38 {
39 friend class wxFont;
40
41 public:
42 wxFontRefData()
43 {
44 Init(10, wxDEFAULT, wxNORMAL, wxNORMAL,
45 false, wxT("applicationfont"), wxFONTENCODING_DEFAULT);
46 }
47
48 wxFontRefData(const wxFontRefData& data)
49 {
50 Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight,
51 data.m_underlined, data.m_faceName, data.m_encoding);
52 }
53
54 wxFontRefData(int size,
55 int family,
56 int style,
57 int weight,
58 bool underlined,
59 const wxString& faceName,
60 wxFontEncoding encoding)
61 {
62 Init(size, family, style, weight, underlined, faceName, encoding);
63 }
64
65 virtual ~wxFontRefData();
66
67 void SetNoAntiAliasing( bool no = true )
68 { m_noAA = no; }
69
70 bool GetNoAntiAliasing() const
71 { return m_noAA; }
72
73 void MacFindFont();
74
75 protected:
76 // common part of all ctors
77 void Init(int size,
78 int family,
79 int style,
80 int weight,
81 bool underlined,
82 const wxString& faceName,
83 wxFontEncoding encoding);
84
85 // font characterstics
86 int m_pointSize;
87 int m_family;
88 int m_style;
89 int m_weight;
90 bool m_underlined;
91 wxString m_faceName;
92 wxFontEncoding m_encoding;
93 bool m_noAA; // No anti-aliasing
94
95 public:
96 #if wxMAC_USE_ATSU_TEXT
97 FMFontFamily m_macFontFamily;
98 FMFontSize m_macFontSize;
99 FMFontStyle m_macFontStyle;
100
101 // ATSU Font Information
102
103 // this is split into an ATSU font id that may
104 // contain some styles (special bold fonts etc) and
105 // these are the additional qd styles that are not
106 // included in the ATSU font id
107 ATSUFontID m_macATSUFontID;
108 FMFontStyle m_macATSUAdditionalQDStyles ;
109
110 // for true themeing support we must store the correct font
111 // information here, as this speeds up and optimizes rendering
112 ThemeFontID m_macThemeFontID ;
113 ATSUStyle m_macATSUStyle ;
114 #endif
115 #if wxMAC_USE_CORE_TEXT
116 wxCFRef<CTFontRef> m_ctFont;
117 CTFontUIFontType m_macUIFontType;
118 #endif
119 wxNativeFontInfo m_info;
120 };
121
122 #define M_FONTDATA ((wxFontRefData*)m_refData)
123
124
125 // ============================================================================
126 // implementation
127 // ============================================================================
128
129 // ----------------------------------------------------------------------------
130 // wxFontRefData
131 // ----------------------------------------------------------------------------
132
133 void wxFontRefData::Init(int pointSize,
134 int family,
135 int style,
136 int weight,
137 bool underlined,
138 const wxString& faceName,
139 wxFontEncoding encoding)
140 {
141 m_style = style;
142 m_pointSize = pointSize;
143 m_family = family;
144 m_style = style;
145 m_weight = weight;
146 m_underlined = underlined;
147 m_faceName = faceName;
148 m_encoding = encoding;
149 m_noAA = false;
150 #if wxMAC_USE_CORE_TEXT
151 m_macUIFontType = kCTFontNoFontType;
152 #endif
153 #if wxMAC_USE_ATSU_TEXT
154 m_macFontFamily = 0 ;
155 m_macFontSize = 0;
156 m_macFontStyle = 0;
157 m_macATSUFontID = 0;
158 m_macATSUAdditionalQDStyles = 0 ;
159 m_macThemeFontID = kThemeCurrentPortFont ;
160 m_macATSUStyle = NULL ;
161 #endif
162 }
163
164 wxFontRefData::~wxFontRefData()
165 {
166 #if wxMAC_USE_ATSU_TEXT
167 if ( m_macATSUStyle )
168 {
169 ::ATSUDisposeStyle((ATSUStyle)m_macATSUStyle);
170 m_macATSUStyle = NULL ;
171 }
172 #endif
173 }
174
175 #if wxMAC_USE_CORE_TEXT
176
177 /* code mixed together from 2 different routines from Core Text Manual Common Operations */
178
179 static CTFontRef wxMacCreateCTFont(CFStringRef iFamilyName, CTFontSymbolicTraits iTraits, CGFloat iSize )
180 {
181 CTFontDescriptorRef descriptor = NULL;
182 CFMutableDictionaryRef attributes;
183
184 assert(iFamilyName != NULL);
185 // Create a mutable dictionary to hold our attributes.
186 attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
187 &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
188 check(attributes != NULL);
189
190 if (attributes != NULL) {
191 // Add a family name to our attributes.
192 CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, iFamilyName);
193
194
195 if ( iTraits ) {
196 CFMutableDictionaryRef traits;
197 CFNumberRef symTraits;
198
199 // Create the traits dictionary.
200 symTraits = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type,
201 &iTraits);
202 check(symTraits != NULL);
203
204 if (symTraits != NULL) {
205 // Create a dictionary to hold our traits values.
206 traits = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
207 &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
208 check(traits != NULL);
209
210 if (traits != NULL) {
211 // Add the symbolic traits value to the traits dictionary.
212 CFDictionaryAddValue(traits, kCTFontSymbolicTrait, symTraits);
213
214 // Add the traits attribute to our attributes.
215 CFDictionaryAddValue(attributes, kCTFontTraitsAttribute, traits);
216 CFRelease(traits);
217 }
218 CFRelease(symTraits);
219 }
220 }
221 // Create the font descriptor with our attributes and input size.
222 descriptor = CTFontDescriptorCreateWithAttributes(attributes);
223 check(descriptor != NULL);
224
225 CFRelease(attributes);
226 }
227 // Return our font descriptor.
228 CTFontRef font = CTFontCreateWithFontDescriptor( descriptor, iSize, NULL);
229 CFRelease( descriptor );
230 return font ;
231 }
232
233 #endif
234
235 void wxFontRefData::MacFindFont()
236 {
237
238 #if wxMAC_USE_CORE_TEXT
239 if ( UMAGetSystemVersion() >= 0x1050 )
240 {
241 if ( m_faceName.empty() && m_family == wxDEFAULT && m_macUIFontType == kCTFontNoFontType )
242 {
243 m_macUIFontType = kCTFontSystemFontType;
244 }
245
246 if ( m_macUIFontType != kCTFontNoFontType )
247 {
248 m_ctFont.reset(CTFontCreateUIFontForLanguage( m_macUIFontType, 0.0, NULL ));
249
250 wxMacCFStringHolder name( CTFontCopyFamilyName( m_ctFont ) );
251 m_faceName = name.AsString();
252 if ( CTFontGetSize(m_ctFont) == 0 )
253 {
254 m_ctFont.reset(CTFontCreateUIFontForLanguage( m_macUIFontType, 12, NULL ));
255 }
256
257 m_pointSize = CTFontGetSize(m_ctFont) ;
258 // reset this so that future manipulation don't fall back
259 m_macUIFontType = kCTFontNoFontType;
260 }
261 else
262 {
263 if ( m_faceName.empty() )
264 {
265 switch ( m_family )
266 {
267 case wxSCRIPT :
268 case wxROMAN :
269 case wxDECORATIVE :
270 m_faceName = wxT("Times");
271 break ;
272
273 case wxSWISS :
274 m_faceName = wxT("Lucida Grande");
275 break ;
276
277 case wxMODERN :
278 case wxTELETYPE:
279 m_faceName = wxT("Monaco");
280 break ;
281
282 default:
283 m_faceName = wxT("Times");
284 break ;
285 }
286 }
287
288 wxMacCFStringHolder cf( m_faceName, wxLocale::GetSystemEncoding() );
289 CTFontSymbolicTraits traits = 0;
290
291 if (m_weight == wxBOLD)
292 traits |= kCTFontBoldTrait;
293 if (m_style == wxITALIC || m_style == wxSLANT)
294 traits |= kCTFontItalicTrait;
295
296 m_ctFont.reset( wxMacCreateCTFont( cf, traits, m_pointSize ) );
297 }
298 }
299 #endif
300 #if wxMAC_USE_ATSU_TEXT
301 {
302 OSStatus status = noErr;
303 Str255 qdFontName ;
304 if ( m_macThemeFontID != kThemeCurrentPortFont )
305 {
306 Style style ;
307 GetThemeFont( m_macThemeFontID, GetApplicationScript(), qdFontName, &m_macFontSize, &style );
308 if ( m_macFontSize == 0 )
309 m_macFontSize = 12;
310 m_macFontStyle = style ;
311 m_faceName = wxMacMakeStringFromPascal( qdFontName );
312 if ( m_macFontStyle & bold )
313 m_weight = wxBOLD ;
314 else
315 m_weight = wxNORMAL ;
316 if ( m_macFontStyle & italic )
317 m_style = wxITALIC ;
318 if ( m_macFontStyle & underline )
319 m_underlined = true ;
320 m_pointSize = m_macFontSize ;
321 m_macFontFamily = FMGetFontFamilyFromName( qdFontName );
322 }
323 else
324 {
325 if ( m_faceName.empty() )
326 {
327 if ( m_family == wxDEFAULT )
328 {
329 m_macFontFamily = GetAppFont();
330 FMGetFontFamilyName(m_macFontFamily,qdFontName);
331 m_faceName = wxMacMakeStringFromPascal( qdFontName );
332 }
333 else
334 {
335 switch ( m_family )
336 {
337 case wxSCRIPT :
338 case wxROMAN :
339 case wxDECORATIVE :
340 m_faceName = wxT("Times");
341 break ;
342
343 case wxSWISS :
344 m_faceName = wxT("Lucida Grande");
345 break ;
346
347 case wxMODERN :
348 case wxTELETYPE:
349 m_faceName = wxT("Monaco");
350 break ;
351
352 default:
353 m_faceName = wxT("Times");
354 break ;
355 }
356 wxMacStringToPascal( m_faceName , qdFontName );
357 m_macFontFamily = FMGetFontFamilyFromName( qdFontName );
358 if ( m_macFontFamily == kInvalidFontFamily )
359 {
360 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for %s"), m_faceName.c_str() );
361 m_macFontFamily = GetAppFont();
362 }
363 }
364 }
365 else
366 {
367 if ( m_faceName == wxT("systemfont") )
368 m_macFontFamily = GetSysFont();
369 else if ( m_faceName == wxT("applicationfont") )
370 m_macFontFamily = GetAppFont();
371 else
372 {
373 wxMacCFStringHolder cf( m_faceName, wxLocale::GetSystemEncoding() );
374 ATSFontFamilyRef atsfamily = ATSFontFamilyFindFromName( cf , kATSOptionFlagsDefault );
375 if ( atsfamily == (ATSFontFamilyRef) -1 )
376 {
377 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for ") + m_faceName );
378 m_macFontFamily = GetAppFont();
379 }
380 else
381 m_macFontFamily = FMGetFontFamilyFromATSFontFamilyRef( atsfamily );
382 }
383 }
384
385 m_macFontStyle = 0;
386 if (m_weight == wxBOLD)
387 m_macFontStyle |= bold;
388 if (m_style == wxITALIC || m_style == wxSLANT)
389 m_macFontStyle |= italic;
390 if (m_underlined)
391 m_macFontStyle |= underline;
392 m_macFontSize = m_pointSize ;
393 }
394
395 // we try to get as much styles as possible into ATSU
396
397
398 // ATSUFontID and FMFont are equivalent
399 FMFontStyle intrinsicStyle = 0 ;
400 status = FMGetFontFromFontFamilyInstance( m_macFontFamily , m_macFontStyle , &m_macATSUFontID , &intrinsicStyle);
401 wxASSERT_MSG( status == noErr , wxT("couldn't get an ATSUFont from font family") );
402 m_macATSUAdditionalQDStyles = m_macFontStyle & (~intrinsicStyle );
403
404 if ( m_macATSUStyle )
405 {
406 ::ATSUDisposeStyle((ATSUStyle)m_macATSUStyle);
407 m_macATSUStyle = NULL ;
408 }
409
410 status = ::ATSUCreateStyle((ATSUStyle *)&m_macATSUStyle);
411 wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") );
412
413 ATSUAttributeTag atsuTags[] =
414 {
415 kATSUFontTag ,
416 kATSUSizeTag ,
417 kATSUVerticalCharacterTag,
418 kATSUQDBoldfaceTag ,
419 kATSUQDItalicTag ,
420 kATSUQDUnderlineTag ,
421 kATSUQDCondensedTag ,
422 kATSUQDExtendedTag ,
423 };
424 ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
425 {
426 sizeof( ATSUFontID ) ,
427 sizeof( Fixed ) ,
428 sizeof( ATSUVerticalCharacterType),
429 sizeof( Boolean ) ,
430 sizeof( Boolean ) ,
431 sizeof( Boolean ) ,
432 sizeof( Boolean ) ,
433 sizeof( Boolean ) ,
434 };
435
436 Boolean kTrue = true ;
437 Boolean kFalse = false ;
438
439 Fixed atsuSize = IntToFixed( m_macFontSize );
440 ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
441 ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
442 {
443 &m_macATSUFontID ,
444 &atsuSize ,
445 &kHorizontal,
446 (m_macATSUAdditionalQDStyles & bold) ? &kTrue : &kFalse ,
447 (m_macATSUAdditionalQDStyles & italic) ? &kTrue : &kFalse ,
448 (m_macATSUAdditionalQDStyles & underline) ? &kTrue : &kFalse ,
449 (m_macATSUAdditionalQDStyles & condense) ? &kTrue : &kFalse ,
450 (m_macATSUAdditionalQDStyles & extend) ? &kTrue : &kFalse ,
451 };
452
453 status = ::ATSUSetAttributes(
454 (ATSUStyle)m_macATSUStyle,
455 sizeof(atsuTags) / sizeof(ATSUAttributeTag) ,
456 atsuTags, atsuSizes, atsuValues);
457
458 wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") );
459 return;
460 }
461 #endif
462 }
463
464 // ----------------------------------------------------------------------------
465 // wxFont
466 // ----------------------------------------------------------------------------
467
468 bool wxFont::Create(const wxNativeFontInfo& info)
469 {
470 return Create(
471 info.pointSize, info.family, info.style, info.weight,
472 info.underlined, info.faceName, info.encoding );
473 }
474
475 wxFont::wxFont(const wxString& fontdesc)
476 {
477 wxNativeFontInfo info;
478 if ( info.FromString(fontdesc) )
479 (void)Create(info);
480 }
481
482 bool wxFont::Create(int pointSize,
483 int family,
484 int style,
485 int weight,
486 bool underlined,
487 const wxString& faceName,
488 wxFontEncoding encoding)
489 {
490 UnRef();
491
492 m_refData = new wxFontRefData(
493 pointSize, family, style, weight,
494 underlined, faceName, encoding);
495
496 RealizeResource();
497
498 return true;
499 }
500
501 #if wxMAC_USE_CORE_TEXT
502
503 bool wxFont::MacCreateUIFont(wxUint32 ctFontType )
504 {
505 UnRef();
506
507 m_refData = new wxFontRefData(
508 12, wxDEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL,
509 false, wxEmptyString, wxFONTENCODING_DEFAULT );
510
511 M_FONTDATA->m_macUIFontType = ctFontType ;
512 RealizeResource();
513
514 return true;
515 }
516
517 #endif
518
519 bool wxFont::MacCreateThemeFont(wxUint16 themeFontID)
520 {
521 #if wxMAC_USE_CORE_TEXT
522 if ( UMAGetSystemVersion() >= 0x1050)
523 {
524 return MacCreateUIFont(HIThemeGetUIFontType(themeFontID));
525 }
526 #endif
527 #if wxMAC_USE_ATSU_TEXT
528 {
529 UnRef();
530
531 m_refData = new wxFontRefData(
532 12, wxDEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL,
533 false, wxEmptyString, wxFONTENCODING_DEFAULT );
534
535 M_FONTDATA->m_macThemeFontID = themeFontID ;
536 RealizeResource();
537 return true;
538 }
539 #endif
540 return false;
541 }
542
543 wxFont::~wxFont()
544 {
545 }
546
547 bool wxFont::RealizeResource()
548 {
549 M_FONTDATA->MacFindFont();
550
551 return true;
552 }
553
554 void wxFont::SetEncoding(wxFontEncoding encoding)
555 {
556 Unshare();
557
558 M_FONTDATA->m_encoding = encoding;
559
560 RealizeResource();
561 }
562
563 void wxFont::Unshare()
564 {
565 // Don't change shared data
566 if (!m_refData)
567 {
568 m_refData = new wxFontRefData();
569 }
570 else
571 {
572 wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
573 UnRef();
574 m_refData = ref;
575 }
576 }
577
578 void wxFont::SetPointSize(int pointSize)
579 {
580 if ( M_FONTDATA->m_pointSize == pointSize )
581 return;
582
583 Unshare();
584
585 M_FONTDATA->m_pointSize = pointSize;
586
587 RealizeResource();
588 }
589
590 void wxFont::SetFamily(int family)
591 {
592 Unshare();
593
594 M_FONTDATA->m_family = family;
595
596 RealizeResource();
597 }
598
599 void wxFont::SetStyle(int style)
600 {
601 Unshare();
602
603 M_FONTDATA->m_style = style;
604
605 RealizeResource();
606 }
607
608 void wxFont::SetWeight(int weight)
609 {
610 Unshare();
611
612 M_FONTDATA->m_weight = weight;
613
614 RealizeResource();
615 }
616
617 bool wxFont::SetFaceName(const wxString& faceName)
618 {
619 Unshare();
620
621 M_FONTDATA->m_faceName = faceName;
622
623 RealizeResource();
624
625 return wxFontBase::SetFaceName(faceName);
626 }
627
628 void wxFont::SetUnderlined(bool underlined)
629 {
630 Unshare();
631
632 M_FONTDATA->m_underlined = underlined;
633
634 RealizeResource();
635 }
636
637 void wxFont::SetNoAntiAliasing( bool no )
638 {
639 Unshare();
640
641 M_FONTDATA->SetNoAntiAliasing( no );
642
643 RealizeResource();
644 }
645
646 // ----------------------------------------------------------------------------
647 // accessors
648 // ----------------------------------------------------------------------------
649
650 // TODO: insert checks everywhere for M_FONTDATA == NULL!
651
652 int wxFont::GetPointSize() const
653 {
654 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
655
656 return M_FONTDATA->m_pointSize;
657 }
658
659 wxSize wxFont::GetPixelSize() const
660 {
661 #if wxUSE_GRAPHICS_CONTEXT
662 // TODO: consider caching the value
663 wxGraphicsContext* dc = wxGraphicsContext::CreateFromNative((CGContextRef) NULL);
664 dc->SetFont(*(wxFont *)this,*wxBLACK);
665 wxDouble width, height = 0;
666 dc->GetTextExtent( wxT("g"), &width, &height, NULL, NULL);
667 delete dc;
668 return wxSize((int)width, (int)height);
669 #else
670 return wxFontBase::GetPixelSize();
671 #endif
672 }
673
674 int wxFont::GetFamily() const
675 {
676 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
677
678 return M_FONTDATA->m_family;
679 }
680
681 int wxFont::GetStyle() const
682 {
683 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
684
685 return M_FONTDATA->m_style;
686 }
687
688 int wxFont::GetWeight() const
689 {
690 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
691
692 return M_FONTDATA->m_weight;
693 }
694
695 bool wxFont::GetUnderlined() const
696 {
697 wxCHECK_MSG( M_FONTDATA != NULL , false, wxT("invalid font") );
698
699 return M_FONTDATA->m_underlined;
700 }
701
702 wxString wxFont::GetFaceName() const
703 {
704 wxCHECK_MSG( M_FONTDATA != NULL , wxEmptyString , wxT("invalid font") );
705
706 return M_FONTDATA->m_faceName;
707 }
708
709 wxFontEncoding wxFont::GetEncoding() const
710 {
711 wxCHECK_MSG( M_FONTDATA != NULL , wxFONTENCODING_DEFAULT , wxT("invalid font") );
712
713 return M_FONTDATA->m_encoding;
714 }
715
716 bool wxFont::GetNoAntiAliasing() const
717 {
718 wxCHECK_MSG( M_FONTDATA != NULL , false, wxT("invalid font") );
719
720 return M_FONTDATA->m_noAA;
721 }
722
723 #if wxMAC_USE_ATSU_TEXT
724
725 short wxFont::MacGetFontNum() const
726 {
727 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
728
729 return M_FONTDATA->m_macFontFamily;
730 }
731
732 short wxFont::MacGetFontSize() const
733 {
734 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
735
736 return M_FONTDATA->m_macFontSize;
737 }
738
739 wxByte wxFont::MacGetFontStyle() const
740 {
741 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
742
743 return M_FONTDATA->m_macFontStyle;
744 }
745
746 wxUint32 wxFont::MacGetATSUFontID() const
747 {
748 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
749
750 return M_FONTDATA->m_macATSUFontID;
751 }
752
753 void * wxFont::MacGetATSUStyle() const
754 {
755 wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
756
757 return M_FONTDATA->m_macATSUStyle;
758 }
759
760 wxUint32 wxFont::MacGetATSUAdditionalQDStyles() const
761 {
762 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
763
764 return M_FONTDATA->m_macATSUAdditionalQDStyles;
765 }
766
767 wxUint16 wxFont::MacGetThemeFontID() const
768 {
769 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
770
771 return M_FONTDATA->m_macThemeFontID;
772 }
773 #endif
774
775 #if wxMAC_USE_CORE_TEXT
776
777 const void * wxFont::MacGetCTFont() const
778 {
779 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
780
781 return (CTFontRef)(M_FONTDATA->m_ctFont);
782 }
783
784 #endif
785
786 const wxNativeFontInfo * wxFont::GetNativeFontInfo() const
787 {
788 wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
789 wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
790
791 M_FONTDATA->m_info.InitFromFont(*this);
792
793 return &(M_FONTDATA->m_info);
794 }