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