]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/font.cpp
porting forward scrolling fix
[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 #if 0
314 status = ATSUFindFontFromName(m_faceName.c_str(), strlen(m_faceName.c_str()), kFontFamilyName, kFontNoPlatform, kFontNoScript, kFontNoLanguage, &atsuFontID);
315 if ( status != noErr )
316 {
317 attributeCount--;
318 }
319 #endif
320 ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
321 {
322 &atsuSize ,
323 &kHorizontal,
324 (m_macATSUAdditionalQDStyles & bold) ? &kTrue : &kFalse ,
325 (m_macATSUAdditionalQDStyles & italic) ? &kTrue : &kFalse ,
326 (m_macATSUAdditionalQDStyles & underline) ? &kTrue : &kFalse ,
327 (m_macATSUAdditionalQDStyles & condense) ? &kTrue : &kFalse ,
328 (m_macATSUAdditionalQDStyles & extend) ? &kTrue : &kFalse ,
329 &atsuFontID ,
330 };
331
332 status = ::ATSUSetAttributes( (ATSUStyle)m_macATSUStyle, attributeCount, atsuTags, atsuSizes, atsuValues);
333
334 wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") );
335 #else
336 if ( m_macThemeFontID != kThemeCurrentPortFont )
337 {
338 Style style ;
339 GetThemeFont( m_macThemeFontID, GetApplicationScript(), qdFontName, &m_macFontSize, &style );
340 m_macFontStyle = style ;
341 m_faceName = wxMacMakeStringFromPascal( qdFontName );
342 if ( m_macFontStyle & bold )
343 m_weight = wxBOLD ;
344 else
345 m_weight = wxNORMAL ;
346 if ( m_macFontStyle & italic )
347 m_style = wxITALIC ;
348 if ( m_macFontStyle & underline )
349 m_underlined = true ;
350 m_pointSize = m_macFontSize ;
351 m_macFontFamily = FMGetFontFamilyFromName( qdFontName );
352 }
353 else
354 {
355 if ( m_faceName.empty() )
356 {
357 if ( m_family == wxDEFAULT )
358 {
359 m_macFontFamily = GetAppFont();
360 FMGetFontFamilyName(m_macFontFamily,qdFontName);
361 m_faceName = wxMacMakeStringFromPascal( qdFontName );
362 }
363 else
364 {
365 switch ( m_family )
366 {
367 case wxSCRIPT :
368 case wxROMAN :
369 case wxDECORATIVE :
370 m_faceName = wxT("Times");
371 break ;
372
373 case wxSWISS :
374 m_faceName = wxT("Lucida Grande");
375 break ;
376
377 case wxMODERN :
378 case wxTELETYPE:
379 m_faceName = wxT("Monaco");
380 break ;
381
382 default:
383 m_faceName = wxT("Times");
384 break ;
385 }
386 wxMacStringToPascal( m_faceName , qdFontName );
387 m_macFontFamily = FMGetFontFamilyFromName( qdFontName );
388 if ( m_macFontFamily == kInvalidFontFamily )
389 {
390 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for %s"), m_faceName.c_str() );
391 m_macFontFamily = GetAppFont();
392 }
393 }
394 }
395 else
396 {
397 if ( m_faceName == wxT("systemfont") )
398 m_macFontFamily = GetSysFont();
399 else if ( m_faceName == wxT("applicationfont") )
400 m_macFontFamily = GetAppFont();
401 else
402 {
403 wxMacCFStringHolder cf( m_faceName, wxLocale::GetSystemEncoding() );
404 ATSFontFamilyRef atsfamily = ATSFontFamilyFindFromName( cf , kATSOptionFlagsDefault );
405 if ( atsfamily == (ATSFontFamilyRef) -1 )
406 {
407 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for ") + m_faceName );
408 m_macFontFamily = GetAppFont();
409 }
410 else
411 m_macFontFamily = FMGetFontFamilyFromATSFontFamilyRef( atsfamily );
412 }
413 }
414
415 m_macFontStyle = 0;
416 if (m_weight == wxBOLD)
417 m_macFontStyle |= bold;
418 if (m_style == wxITALIC || m_style == wxSLANT)
419 m_macFontStyle |= italic;
420 if (m_underlined)
421 m_macFontStyle |= underline;
422 m_macFontSize = m_pointSize ;
423 }
424
425 // we try to get as much styles as possible into ATSU
426
427
428 // ATSUFontID and FMFont are equivalent
429 FMFontStyle intrinsicStyle = 0 ;
430 status = FMGetFontFromFontFamilyInstance( m_macFontFamily , m_macFontStyle , &m_macATSUFontID , &intrinsicStyle);
431 wxASSERT_MSG( status == noErr , wxT("couldn't get an ATSUFont from font family") );
432 m_macATSUAdditionalQDStyles = m_macFontStyle & (~intrinsicStyle );
433
434 if ( m_macATSUStyle )
435 {
436 ::ATSUDisposeStyle((ATSUStyle)m_macATSUStyle);
437 m_macATSUStyle = NULL ;
438 }
439
440 status = ::ATSUCreateStyle((ATSUStyle *)&m_macATSUStyle);
441 wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") );
442
443 ATSUAttributeTag atsuTags[] =
444 {
445 kATSUFontTag ,
446 kATSUSizeTag ,
447 kATSUVerticalCharacterTag,
448 kATSUQDBoldfaceTag ,
449 kATSUQDItalicTag ,
450 kATSUQDUnderlineTag ,
451 kATSUQDCondensedTag ,
452 kATSUQDExtendedTag ,
453 };
454 ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
455 {
456 sizeof( ATSUFontID ) ,
457 sizeof( Fixed ) ,
458 sizeof( ATSUVerticalCharacterType),
459 sizeof( Boolean ) ,
460 sizeof( Boolean ) ,
461 sizeof( Boolean ) ,
462 sizeof( Boolean ) ,
463 sizeof( Boolean ) ,
464 };
465
466 Boolean kTrue = true ;
467 Boolean kFalse = false ;
468
469 Fixed atsuSize = IntToFixed( m_macFontSize );
470 ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
471 ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
472 {
473 &m_macATSUFontID ,
474 &atsuSize ,
475 &kHorizontal,
476 (m_macATSUAdditionalQDStyles & bold) ? &kTrue : &kFalse ,
477 (m_macATSUAdditionalQDStyles & italic) ? &kTrue : &kFalse ,
478 (m_macATSUAdditionalQDStyles & underline) ? &kTrue : &kFalse ,
479 (m_macATSUAdditionalQDStyles & condense) ? &kTrue : &kFalse ,
480 (m_macATSUAdditionalQDStyles & extend) ? &kTrue : &kFalse ,
481 };
482
483 status = ::ATSUSetAttributes(
484 (ATSUStyle)m_macATSUStyle,
485 sizeof(atsuTags) / sizeof(ATSUAttributeTag) ,
486 atsuTags, atsuSizes, atsuValues);
487
488 wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") );
489 #endif
490 }
491
492 // ----------------------------------------------------------------------------
493 // wxFont
494 // ----------------------------------------------------------------------------
495
496 bool wxFont::Create(const wxNativeFontInfo& info)
497 {
498 return Create(
499 info.pointSize, info.family, info.style, info.weight,
500 info.underlined, info.faceName, info.encoding );
501 }
502
503 wxFont::wxFont(const wxString& fontdesc)
504 {
505 wxNativeFontInfo info;
506 if ( info.FromString(fontdesc) )
507 (void)Create(info);
508 }
509
510 bool wxFont::Create(int pointSize,
511 int family,
512 int style,
513 int weight,
514 bool underlined,
515 const wxString& faceName,
516 wxFontEncoding encoding)
517 {
518 UnRef();
519
520 m_refData = new wxFontRefData(
521 pointSize, family, style, weight,
522 underlined, faceName, encoding);
523
524 RealizeResource();
525
526 return true;
527 }
528
529 #ifdef __LP64__
530
531 bool wxFont::MacCreateUIFont(wxUint32 ctFontType )
532 {
533 UnRef();
534
535 m_refData = new wxFontRefData(
536 12, wxDEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL,
537 false, wxEmptyString, wxFONTENCODING_DEFAULT );
538
539 M_FONTDATA->m_macUIFontType = ctFontType ;
540 RealizeResource();
541
542 return true;
543 }
544
545 #endif
546
547 bool wxFont::MacCreateThemeFont(wxUint16 themeFontID)
548 {
549 #ifdef __LP64__
550 return MacCreateUIFont(HIThemeGetUIFontType(themeFontID));
551 #else
552 UnRef();
553
554 m_refData = new wxFontRefData(
555 12, wxDEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL,
556 false, wxEmptyString, wxFONTENCODING_DEFAULT );
557
558 M_FONTDATA->m_macThemeFontID = themeFontID ;
559 RealizeResource();
560
561 return true;
562 #endif
563 }
564
565 wxFont::~wxFont()
566 {
567 }
568
569 bool wxFont::RealizeResource()
570 {
571 M_FONTDATA->MacFindFont();
572
573 return true;
574 }
575
576 void wxFont::SetEncoding(wxFontEncoding encoding)
577 {
578 Unshare();
579
580 M_FONTDATA->m_encoding = encoding;
581
582 RealizeResource();
583 }
584
585 void wxFont::Unshare()
586 {
587 // Don't change shared data
588 if (!m_refData)
589 {
590 m_refData = new wxFontRefData();
591 }
592 else
593 {
594 wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
595 UnRef();
596 m_refData = ref;
597 }
598 }
599
600 void wxFont::SetPointSize(int pointSize)
601 {
602 Unshare();
603
604 M_FONTDATA->m_pointSize = pointSize;
605
606 RealizeResource();
607 }
608
609 void wxFont::SetFamily(int family)
610 {
611 Unshare();
612
613 M_FONTDATA->m_family = family;
614
615 RealizeResource();
616 }
617
618 void wxFont::SetStyle(int style)
619 {
620 Unshare();
621
622 M_FONTDATA->m_style = style;
623
624 RealizeResource();
625 }
626
627 void wxFont::SetWeight(int weight)
628 {
629 Unshare();
630
631 M_FONTDATA->m_weight = weight;
632
633 RealizeResource();
634 }
635
636 bool wxFont::SetFaceName(const wxString& faceName)
637 {
638 Unshare();
639
640 M_FONTDATA->m_faceName = faceName;
641
642 RealizeResource();
643
644 return wxFontBase::SetFaceName(faceName);
645 }
646
647 void wxFont::SetUnderlined(bool underlined)
648 {
649 Unshare();
650
651 M_FONTDATA->m_underlined = underlined;
652
653 RealizeResource();
654 }
655
656 void wxFont::SetNoAntiAliasing( bool no )
657 {
658 Unshare();
659
660 M_FONTDATA->SetNoAntiAliasing( no );
661
662 RealizeResource();
663 }
664
665 // ----------------------------------------------------------------------------
666 // accessors
667 // ----------------------------------------------------------------------------
668
669 // TODO: insert checks everywhere for M_FONTDATA == NULL!
670
671 int wxFont::GetPointSize() const
672 {
673 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
674
675 return M_FONTDATA->m_pointSize;
676 }
677
678 wxSize wxFont::GetPixelSize() const
679 {
680 #if wxUSE_GRAPHICS_CONTEXT
681 // TODO: consider caching the value
682 wxGraphicsContext* dc = wxGraphicsContext::CreateFromNative((CGContextRef) NULL);
683 dc->SetFont(*(wxFont *)this,*wxBLACK);
684 wxDouble width, height = 0;
685 dc->GetTextExtent( wxT("g"), &width, &height, NULL, NULL);
686 delete dc;
687 return wxSize((int)width, (int)height);
688 #else
689 return wxFontBase::GetPixelSize();
690 #endif
691 }
692
693 int wxFont::GetFamily() const
694 {
695 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
696
697 return M_FONTDATA->m_family;
698 }
699
700 int wxFont::GetStyle() const
701 {
702 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
703
704 return M_FONTDATA->m_style;
705 }
706
707 int wxFont::GetWeight() const
708 {
709 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
710
711 return M_FONTDATA->m_weight;
712 }
713
714 bool wxFont::GetUnderlined() const
715 {
716 wxCHECK_MSG( M_FONTDATA != NULL , false, wxT("invalid font") );
717
718 return M_FONTDATA->m_underlined;
719 }
720
721 wxString wxFont::GetFaceName() const
722 {
723 wxCHECK_MSG( M_FONTDATA != NULL , wxEmptyString , wxT("invalid font") );
724
725 return M_FONTDATA->m_faceName;
726 }
727
728 wxFontEncoding wxFont::GetEncoding() const
729 {
730 wxCHECK_MSG( M_FONTDATA != NULL , wxFONTENCODING_DEFAULT , wxT("invalid font") );
731
732 return M_FONTDATA->m_encoding;
733 }
734
735 bool wxFont::GetNoAntiAliasing() const
736 {
737 wxCHECK_MSG( M_FONTDATA != NULL , false, wxT("invalid font") );
738
739 return M_FONTDATA->m_noAA;
740 }
741
742 #ifndef __LP64__
743
744 short wxFont::MacGetFontNum() const
745 {
746 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
747
748 return M_FONTDATA->m_macFontFamily;
749 }
750
751 short wxFont::MacGetFontSize() const
752 {
753 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
754
755 return M_FONTDATA->m_macFontSize;
756 }
757
758 wxByte wxFont::MacGetFontStyle() const
759 {
760 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
761
762 return M_FONTDATA->m_macFontStyle;
763 }
764
765 wxUint32 wxFont::MacGetATSUFontID() const
766 {
767 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
768
769 return M_FONTDATA->m_macATSUFontID;
770 }
771
772 void * wxFont::MacGetATSUStyle() const
773 {
774 wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
775
776 return M_FONTDATA->m_macATSUStyle;
777 }
778
779 wxUint32 wxFont::MacGetATSUAdditionalQDStyles() const
780 {
781 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
782
783 return M_FONTDATA->m_macATSUAdditionalQDStyles;
784 }
785
786 wxUint16 wxFont::MacGetThemeFontID() const
787 {
788 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
789
790 return M_FONTDATA->m_macThemeFontID;
791 }
792 #else
793 const void * wxFont::MacGetCTFont() const
794 {
795 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
796
797 return M_FONTDATA->m_macFontRef;
798 }
799
800 // to be removed
801 void * wxFont::MacGetATSUStyle() const
802 {
803 wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
804
805 return M_FONTDATA->m_macATSUStyle;
806 }
807
808 #endif
809
810 const wxNativeFontInfo * wxFont::GetNativeFontInfo() const
811 {
812 wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
813 wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
814
815 M_FONTDATA->m_info.InitFromFont(*this);
816
817 return &(M_FONTDATA->m_info);
818 }