]> git.saurik.com Git - wxWidgets.git/blame - src/osx/carbon/font.cpp
Significantly improved wxPropertyGrid's top-level parent change detection code (fixes...
[wxWidgets.git] / src / osx / carbon / font.cpp
CommitLineData
489468fe 1/////////////////////////////////////////////////////////////////////////////
524c47aa 2// Name: src/osx/carbon/font.cpp
489468fe
SC
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#include "wx/settings.h"
f1c40652 27#include "wx/tokenzr.h"
489468fe 28
b2680ced 29#include "wx/osx/private.h"
29e32b7f
SC
30
31#if wxOSX_USE_ATSU_TEXT && !wxOSX_USE_CARBON
32// include themeing support
33#include <Carbon/Carbon.h>
b2680ced 34#endif
489468fe 35
489468fe
SC
36#include <map>
37#include <string>
38
39IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
40
489468fe
SC
41class WXDLLEXPORT wxFontRefData: public wxGDIRefData
42{
43public:
489468fe 44
f1c40652 45 wxFontRefData()
489468fe 46 {
f1c40652
SC
47 Init();
48 m_info.Init(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL,
49 false, wxEmptyString, wxFONTENCODING_DEFAULT);
489468fe
SC
50 }
51
f1c40652
SC
52 wxFontRefData(const wxFontRefData& data);
53
54 wxFontRefData( const wxNativeFontInfo& info ) : m_info(info)
489468fe 55 {
f1c40652 56 Init();
489468fe
SC
57 }
58
f1c40652
SC
59 wxFontRefData(wxOSXSystemFont font, int size);
60
292e5e1f 61#if wxOSX_USE_CORE_TEXT
489468fe
SC
62 wxFontRefData( wxUint32 coreTextFontType );
63 wxFontRefData( CTFontRef font );
64 wxFontRefData( CTFontDescriptorRef fontdescriptor, int size );
65#endif
66
67 virtual ~wxFontRefData();
68
69 void SetNoAntiAliasing( bool no = true ) { m_noAA = no; }
70
71 bool GetNoAntiAliasing() const { return m_noAA; }
72
73 void SetPointSize( int size )
74 {
f1c40652
SC
75 if( GetPointSize() != size )
76 {
77 m_info.SetPointSize(size);
78 Free();
79 }
489468fe
SC
80 }
81
f1c40652 82 int GetPointSize() const { return m_info.GetPointSize(); }
489468fe 83
0c14b6c3 84 void SetFamily( wxFontFamily family )
489468fe 85 {
f1c40652
SC
86 if ( m_info.m_family != family )
87 {
88 m_info.SetFamily( family );
89 Free();
90 }
489468fe
SC
91 }
92
f1c40652 93 wxFontFamily GetFamily() const { return m_info.GetFamily(); }
489468fe 94
0c14b6c3 95 void SetStyle( wxFontStyle style )
489468fe 96 {
f1c40652
SC
97 if ( m_info.m_style != style )
98 {
99 m_info.SetStyle( style );
100 Free();
101 }
489468fe
SC
102 }
103
104
f1c40652 105 wxFontStyle GetStyle() const { return m_info.GetStyle(); }
489468fe 106
0c14b6c3 107 void SetWeight( wxFontWeight weight )
489468fe 108 {
f1c40652
SC
109 if ( m_info.m_weight != weight )
110 {
111 m_info.SetWeight( weight );
112 Free();
113 }
489468fe
SC
114 }
115
116
f1c40652 117 wxFontWeight GetWeight() const { return m_info.GetWeight(); }
489468fe
SC
118
119 void SetUnderlined( bool u )
120 {
f1c40652
SC
121 if ( m_info.m_underlined != u )
122 {
123 m_info.SetUnderlined( u );
124 Free();
125 }
489468fe
SC
126 }
127
f1c40652 128 bool GetUnderlined() const { return m_info.GetUnderlined(); }
489468fe
SC
129
130 void SetFaceName( const wxString& facename )
131 {
f1c40652
SC
132 if ( m_info.m_faceName != facename )
133 {
134 m_info.SetFaceName( facename );
135 Free();
136 }
489468fe
SC
137 }
138
f1c40652 139 wxString GetFaceName() const { return m_info.GetFaceName(); }
489468fe
SC
140
141 void SetEncoding( wxFontEncoding encoding )
142 {
f1c40652
SC
143 if ( m_info.m_encoding != encoding )
144 {
145 m_info.SetEncoding( encoding );
146 Free();
147 }
489468fe
SC
148 }
149
f1c40652 150 wxFontEncoding GetEncoding() const { return m_info.GetEncoding(); }
489468fe 151
f1c40652 152 void Free();
489468fe
SC
153
154 void MacFindFont();
155
156protected:
157 // common part of all ctors
f1c40652 158 void Init();
292e5e1f 159#if wxOSX_USE_CORE_TEXT
f1c40652 160 // void Init( CTFontRef font );
489468fe 161#endif
489468fe 162 bool m_noAA; // No anti-aliasing
489468fe 163public:
f1c40652
SC
164 bool m_fontValid;
165#if wxOSX_USE_CARBON && wxOSX_USE_ATSU_TEXT
489468fe
SC
166 // for true themeing support we must store the correct font
167 // information here, as this speeds up and optimizes rendering
168 ThemeFontID m_macThemeFontID ;
169#endif
292e5e1f 170#if wxOSX_USE_CORE_TEXT
489468fe 171 wxCFRef<CTFontRef> m_ctFont;
489468fe 172#endif
beb2638a 173#if wxOSX_USE_ATSU_TEXT
489468fe 174 ATSUStyle m_macATSUStyle ;
f1c40652 175#endif
9445de1e 176 wxCFRef<CGFontRef> m_cgFont;
f1c40652
SC
177#if wxOSX_USE_COCOA
178 WX_NSFont m_nsFont;
179#endif
180#if wxOSX_USE_IPHONE
181 WX_UIFont m_uiFont;
489468fe
SC
182#endif
183 wxNativeFontInfo m_info;
184};
185
186#define M_FONTDATA ((wxFontRefData*)m_refData)
187
f1c40652
SC
188wxFontRefData::wxFontRefData(const wxFontRefData& data)
189{
190 Init();
191 m_info = data.m_info;
192 m_noAA = data.m_noAA;
193 m_fontValid = data.m_fontValid;
194#if wxOSX_USE_CARBON && wxOSX_USE_ATSU_TEXT
195 m_macThemeFontID = data.m_macThemeFontID;
196#endif
197#if wxOSX_USE_CORE_TEXT
198 m_ctFont = data.m_ctFont;
beb2638a 199#endif
9445de1e 200 m_cgFont = data.m_cgFont;
beb2638a 201#if wxOSX_USE_ATSU_TEXT
f1c40652
SC
202 if ( data.m_macATSUStyle != NULL )
203 {
204 ATSUCreateStyle(&m_macATSUStyle) ;
205 ATSUCopyAttributes(data.m_macATSUStyle, m_macATSUStyle);
206 }
207#endif
208#if wxOSX_USE_COCOA
209 m_nsFont = (NSFont*) wxMacCocoaRetain(data.m_nsFont);
210#endif
211#if wxOSX_USE_IPHONE
b4ff8b3e 212 m_uiFont = (UIFont*) wxMacCocoaRetain(data.m_uiFont);
f1c40652
SC
213#endif
214
215}
489468fe
SC
216
217// ============================================================================
218// implementation
219// ============================================================================
220
221// ----------------------------------------------------------------------------
222// wxFontRefData
223// ----------------------------------------------------------------------------
224
f1c40652 225void wxFontRefData::Init()
489468fe 226{
489468fe 227 m_noAA = false;
f1c40652 228#if wxOSX_USE_CARBON && wxOSX_USE_ATSU_TEXT
489468fe
SC
229 m_macThemeFontID = kThemeCurrentPortFont ;
230#endif
beb2638a 231#if wxOSX_USE_ATSU_TEXT
489468fe
SC
232 m_macATSUStyle = NULL ;
233#endif
f1c40652
SC
234#if wxOSX_USE_COCOA
235 m_nsFont = NULL;
236#endif
237#if wxOSX_USE_IPHONE
238 m_uiFont = NULL;
239#endif
240 m_fontValid = false;
489468fe
SC
241}
242
243wxFontRefData::~wxFontRefData()
244{
f1c40652 245 Free();
489468fe
SC
246}
247
f1c40652 248void wxFontRefData::Free()
489468fe 249{
292e5e1f 250#if wxOSX_USE_CORE_TEXT
489468fe 251 m_ctFont.reset();
489468fe 252#endif
9445de1e 253 m_cgFont.reset();
beb2638a 254#if wxOSX_USE_ATSU_TEXT
9581362b
SC
255#if wxOSX_USE_CARBON
256 m_macThemeFontID = kThemeCurrentPortFont ;
257#endif
489468fe
SC
258 if ( m_macATSUStyle )
259 {
260 ::ATSUDisposeStyle((ATSUStyle)m_macATSUStyle);
261 m_macATSUStyle = NULL ;
262 }
263#endif
f1c40652
SC
264#if wxOSX_USE_COCOA
265 if (m_nsFont != NULL)
266 {
267 wxMacCocoaRelease(m_nsFont);
268 m_nsFont = NULL;
489468fe 269 }
f1c40652
SC
270#endif
271#if wxOSX_USE_IPHONE
272 if (m_uiFont != NULL)
489468fe 273 {
f1c40652
SC
274 wxMacCocoaRelease(m_uiFont);
275 m_uiFont = NULL;
489468fe 276 }
f1c40652
SC
277#endif
278 m_fontValid = false;
489468fe
SC
279}
280
f1c40652 281wxFontRefData::wxFontRefData(wxOSXSystemFont font, int size)
489468fe 282{
f1c40652
SC
283 wxASSERT( font != wxOSX_SYSTEM_FONT_NONE );
284 Init();
285
286#if wxOSX_USE_CORE_TEXT
287 if ( UMAGetSystemVersion() >= 0x1050 )
489468fe 288 {
de0d2095 289 CTFontUIFontType uifont = kCTFontSystemFontType;
f1c40652 290 switch( font )
489468fe 291 {
f1c40652
SC
292 case wxOSX_SYSTEM_FONT_NORMAL:
293 uifont = kCTFontSystemFontType;
294 break;
295 case wxOSX_SYSTEM_FONT_BOLD:
296 uifont = kCTFontEmphasizedSystemFontType;
297 break;
298 case wxOSX_SYSTEM_FONT_SMALL:
299 uifont = kCTFontSmallSystemFontType;
300 break;
301 case wxOSX_SYSTEM_FONT_SMALL_BOLD:
302 uifont = kCTFontSmallEmphasizedSystemFontType;
303 break;
304 case wxOSX_SYSTEM_FONT_MINI:
305 uifont = kCTFontMiniSystemFontType;
306 break;
307 case wxOSX_SYSTEM_FONT_MINI_BOLD:
308 uifont = kCTFontMiniEmphasizedSystemFontType;
309 break;
310 case wxOSX_SYSTEM_FONT_LABELS:
311 uifont = kCTFontLabelFontType;
312 break;
313 case wxOSX_SYSTEM_FONT_VIEWS:
314 uifont = kCTFontViewsFontType;
315 break;
316 default:
317 break;
489468fe 318 }
f1c40652
SC
319 m_ctFont.reset(CTFontCreateUIFontForLanguage( uifont, (CGFloat) size, NULL ));
320 wxCFRef<CTFontDescriptorRef> descr;
321 descr.reset( CTFontCopyFontDescriptor( m_ctFont ) );
322 m_info.Init(descr);
323 }
324#endif
325#if wxOSX_USE_ATSU_TEXT
326 {
9a672c75
SC
327#if !wxOSX_USE_CARBON
328 // not needed outside
de0d2095 329 ThemeFontID m_macThemeFontID = kThemeSystemFont;
9a672c75 330#endif
f1c40652
SC
331 switch( font )
332 {
333 case wxOSX_SYSTEM_FONT_NORMAL:
334 m_macThemeFontID = kThemeSystemFont;
335 break;
336 case wxOSX_SYSTEM_FONT_BOLD:
337 m_macThemeFontID = kThemeEmphasizedSystemFont;
338 break;
339 case wxOSX_SYSTEM_FONT_SMALL:
340 m_macThemeFontID = kThemeSmallSystemFont;
341 break;
342 case wxOSX_SYSTEM_FONT_SMALL_BOLD:
343 m_macThemeFontID = kThemeSmallEmphasizedSystemFont;
344 break;
345 case wxOSX_SYSTEM_FONT_MINI:
346 m_macThemeFontID = kThemeMiniSystemFont;
347 break;
348 case wxOSX_SYSTEM_FONT_MINI_BOLD:
349 // bold not available under themeing
350 m_macThemeFontID = kThemeMiniSystemFont;
351 break;
352 case wxOSX_SYSTEM_FONT_LABELS:
353 m_macThemeFontID = kThemeLabelFont;
354 break;
355 case wxOSX_SYSTEM_FONT_VIEWS:
356 m_macThemeFontID = kThemeViewsFont;
357 break;
358 default:
359 break;
360 }
361 if ( m_info.m_faceName.empty() )
362 {
363 Style style ;
364 FMFontSize fontSize;
365 Str255 qdFontName ;
366
367 GetThemeFont( m_macThemeFontID, GetApplicationScript(), qdFontName, &fontSize, &style );
368 if ( size != 0 )
369 fontSize = size;
370
371 wxFontStyle fontstyle = wxFONTSTYLE_NORMAL;
372 wxFontWeight fontweight = wxFONTWEIGHT_NORMAL;
373 bool underlined = false;
374
375 if ( style & bold )
376 fontweight = wxFONTWEIGHT_BOLD ;
377 else
378 fontweight = wxFONTWEIGHT_NORMAL ;
379 if ( style & italic )
380 fontstyle = wxFONTSTYLE_ITALIC ;
381 if ( style & underline )
382 underlined = true ;
383
2ff0354a 384 m_info.Init(fontSize,wxFONTFAMILY_DEFAULT,fontstyle,fontweight,underlined,
f1c40652
SC
385 wxMacMakeStringFromPascal( qdFontName ), wxFONTENCODING_DEFAULT);
386 }
489468fe 387 }
489468fe 388#endif
f1c40652 389#if wxOSX_USE_COCOA
aa6208d9 390 m_nsFont = wxFont::OSXCreateNSFont( font, &m_info );
f1c40652
SC
391#endif
392#if wxOSX_USE_IPHONE
aa6208d9 393 m_uiFont = wxFont::OSXCreateUIFont( font, &m_info );
f1c40652
SC
394#endif
395}
489468fe
SC
396
397void wxFontRefData::MacFindFont()
398{
f1c40652
SC
399 if ( m_fontValid )
400 return;
401
402 m_info.EnsureValid();
403
292e5e1f 404#if wxOSX_USE_CORE_TEXT
489468fe
SC
405 if ( UMAGetSystemVersion() >= 0x1050 )
406 {
f1c40652 407 CTFontSymbolicTraits traits = 0;
0c14b6c3 408
f1c40652
SC
409 if (m_info.m_weight == wxFONTWEIGHT_BOLD)
410 traits |= kCTFontBoldTrait;
411 if (m_info.m_style == wxFONTSTYLE_ITALIC || m_info.m_style == wxFONTSTYLE_SLANT)
412 traits |= kCTFontItalicTrait;
489468fe 413
f1c40652
SC
414 // use font caching
415 wxString lookupnameWithSize = wxString::Format( "%s_%ld_%ld", m_info.m_faceName.c_str(), traits, m_info.m_pointSize );
489468fe 416
f1c40652
SC
417 static std::map< std::wstring , wxCFRef< CTFontRef > > fontcache ;
418 m_ctFont = fontcache[ std::wstring(lookupnameWithSize.wc_str()) ];
419 if ( !m_ctFont )
489468fe 420 {
f1c40652 421 m_ctFont.reset( CTFontCreateWithFontDescriptor( m_info.m_ctFontDescriptor, 0/*m_pointSize */, NULL ) );
489468fe 422 }
9445de1e 423 m_cgFont.reset(CTFontCopyGraphicsFont(m_ctFont, NULL));
489468fe 424 }
f1c40652 425
489468fe 426#endif
292e5e1f 427#if wxOSX_USE_ATSU_TEXT
489468fe 428 {
489468fe
SC
429 // we try to get as much styles as possible into ATSU
430
f1c40652 431 OSStatus status = ::ATSUCreateStyle(&m_macATSUStyle);
489468fe
SC
432 wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") );
433
434 ATSUAttributeTag atsuTags[] =
435 {
436 kATSUFontTag ,
437 kATSUSizeTag ,
438 kATSUVerticalCharacterTag,
439 kATSUQDBoldfaceTag ,
440 kATSUQDItalicTag ,
441 kATSUQDUnderlineTag ,
442 kATSUQDCondensedTag ,
443 kATSUQDExtendedTag ,
444 };
445 ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
446 {
447 sizeof( ATSUFontID ) ,
448 sizeof( Fixed ) ,
449 sizeof( ATSUVerticalCharacterType),
450 sizeof( Boolean ) ,
451 sizeof( Boolean ) ,
452 sizeof( Boolean ) ,
453 sizeof( Boolean ) ,
454 sizeof( Boolean ) ,
455 };
456
457 Boolean kTrue = true ;
458 Boolean kFalse = false ;
459
f1c40652 460 Fixed atsuSize = IntToFixed( m_info.m_pointSize );
489468fe 461 ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
f1c40652 462 FMFontStyle addQDStyle = m_info.m_atsuAdditionalQDStyles;
489468fe
SC
463 ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
464 {
f1c40652 465 &m_info.m_atsuFontID ,
489468fe
SC
466 &atsuSize ,
467 &kHorizontal,
f1c40652
SC
468 (addQDStyle & bold) ? &kTrue : &kFalse ,
469 (addQDStyle & italic) ? &kTrue : &kFalse ,
470 (addQDStyle & underline) ? &kTrue : &kFalse ,
471 (addQDStyle & condense) ? &kTrue : &kFalse ,
472 (addQDStyle & extend) ? &kTrue : &kFalse ,
489468fe
SC
473 };
474
475 status = ::ATSUSetAttributes(
476 (ATSUStyle)m_macATSUStyle,
477 sizeof(atsuTags) / sizeof(ATSUAttributeTag) ,
478 atsuTags, atsuSizes, atsuValues);
479
480 wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") );
9445de1e
SC
481 if ( m_cgFont.get() == NULL )
482 {
483 ATSFontRef fontRef = FMGetATSFontRefFromFont(m_info.m_atsuFontID);
484 m_cgFont.reset( CGFontCreateWithPlatformFont( &fontRef ) );
485 }
489468fe
SC
486 }
487#endif
f1c40652 488#if wxOSX_USE_COCOA
aa6208d9 489 m_nsFont = wxFont::OSXCreateNSFont( &m_info );
f1c40652
SC
490#endif
491#if wxOSX_USE_IPHONE
aa6208d9 492 m_uiFont = wxFont::OSXCreateUIFont( &m_info );
f1c40652
SC
493#endif
494 m_fontValid = true;
489468fe
SC
495}
496
497// ----------------------------------------------------------------------------
498// wxFont
499// ----------------------------------------------------------------------------
500
501bool wxFont::Create(const wxNativeFontInfo& info)
502{
f1c40652
SC
503 UnRef();
504
505 m_refData = new wxFontRefData( info );
506 RealizeResource();
507
508 return true;
489468fe
SC
509}
510
511wxFont::wxFont(const wxString& fontdesc)
512{
513 wxNativeFontInfo info;
514 if ( info.FromString(fontdesc) )
515 (void)Create(info);
516}
517
518bool wxFont::Create(int pointSize,
0c14b6c3
FM
519 wxFontFamily family,
520 wxFontStyle style,
521 wxFontWeight weight,
522 bool underlined,
f1c40652 523 const wxString& faceNameParam,
0c14b6c3 524 wxFontEncoding encoding)
489468fe
SC
525{
526 UnRef();
f1c40652
SC
527
528 wxString faceName = faceNameParam;
489468fe 529
f1c40652
SC
530 if ( faceName.empty() )
531 {
532 switch ( family )
533 {
534 case wxFONTFAMILY_DEFAULT :
535 faceName = wxT("Lucida Grande");
536 break;
537
538 case wxFONTFAMILY_SCRIPT :
539 case wxFONTFAMILY_ROMAN :
540 case wxFONTFAMILY_DECORATIVE :
541 faceName = wxT("Times");
542 break ;
543
544 case wxFONTFAMILY_SWISS :
545 faceName = wxT("Helvetica");
546 break ;
547
548 case wxFONTFAMILY_MODERN :
549 case wxFONTFAMILY_TELETYPE:
550 faceName = wxT("Courier");
551 break ;
552
553 default:
554 faceName = wxT("Times");
555 break ;
556 }
557 }
558
559 wxNativeFontInfo info;
560
561 info.Init(pointSize, family, style, weight,
489468fe
SC
562 underlined, faceName, encoding);
563
f1c40652 564 m_refData = new wxFontRefData(info);
489468fe
SC
565
566 return true;
567}
568
f1c40652 569bool wxFont::CreateSystemFont(wxOSXSystemFont font)
489468fe
SC
570{
571 UnRef();
f1c40652
SC
572
573 m_refData = new wxFontRefData( font, 0 );
574
489468fe
SC
575 return true;
576}
577
f1c40652 578wxFont::~wxFont()
489468fe 579{
f1c40652 580}
489468fe 581
c443ff6f
SC
582void wxFont::DoSetNativeFontInfo(const wxNativeFontInfo& info)
583{
584 UnRef();
585
586 m_refData = new wxFontRefData( info);
587}
588
589
f1c40652
SC
590bool wxFont::RealizeResource()
591{
592 M_FONTDATA->MacFindFont();
489468fe
SC
593
594 return true;
595}
596
f1c40652
SC
597void wxFont::SetEncoding(wxFontEncoding encoding)
598{
599 AllocExclusive();
489468fe
SC
600
601 M_FONTDATA->SetEncoding( encoding );
489468fe
SC
602}
603
604wxGDIRefData *wxFont::CreateGDIRefData() const
605{
606 return new wxFontRefData;
607}
608
609wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const
610{
5c33522f 611 return new wxFontRefData(*static_cast<const wxFontRefData *>(data));
489468fe
SC
612}
613
614void wxFont::SetPointSize(int pointSize)
615{
616 if ( M_FONTDATA->GetPointSize() == pointSize )
617 return;
618
f1c40652 619 AllocExclusive();
489468fe
SC
620
621 M_FONTDATA->SetPointSize( pointSize );
489468fe
SC
622}
623
0c14b6c3 624void wxFont::SetFamily(wxFontFamily family)
489468fe 625{
f1c40652 626 AllocExclusive();
489468fe
SC
627
628 M_FONTDATA->SetFamily( family );
489468fe
SC
629}
630
0c14b6c3 631void wxFont::SetStyle(wxFontStyle style)
489468fe 632{
f1c40652 633 AllocExclusive();
489468fe
SC
634
635 M_FONTDATA->SetStyle( style );
489468fe
SC
636}
637
0c14b6c3 638void wxFont::SetWeight(wxFontWeight weight)
489468fe 639{
f1c40652 640 AllocExclusive();
489468fe
SC
641
642 M_FONTDATA->SetWeight( weight );
489468fe
SC
643}
644
645bool wxFont::SetFaceName(const wxString& faceName)
646{
f1c40652 647 AllocExclusive();
489468fe
SC
648
649 M_FONTDATA->SetFaceName( faceName );
650
489468fe
SC
651 return wxFontBase::SetFaceName(faceName);
652}
653
654void wxFont::SetUnderlined(bool underlined)
655{
f1c40652 656 AllocExclusive();
489468fe
SC
657
658 M_FONTDATA->SetUnderlined( underlined );
489468fe
SC
659}
660
661void wxFont::SetNoAntiAliasing( bool no )
662{
f1c40652 663 AllocExclusive();
489468fe
SC
664
665 M_FONTDATA->SetNoAntiAliasing( no );
489468fe
SC
666}
667
668// ----------------------------------------------------------------------------
669// accessors
670// ----------------------------------------------------------------------------
671
672// TODO: insert checks everywhere for M_FONTDATA == NULL!
673
674int wxFont::GetPointSize() const
675{
676 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
677
678 return M_FONTDATA->GetPointSize();
679}
680
681wxSize wxFont::GetPixelSize() const
682{
683#if wxUSE_GRAPHICS_CONTEXT
684 // TODO: consider caching the value
685 wxGraphicsContext* dc = wxGraphicsContext::CreateFromNative((CGContextRef) NULL);
686 dc->SetFont(*(wxFont *)this,*wxBLACK);
687 wxDouble width, height = 0;
688 dc->GetTextExtent( wxT("g"), &width, &height, NULL, NULL);
689 delete dc;
690 return wxSize((int)width, (int)height);
691#else
692 return wxFontBase::GetPixelSize();
693#endif
694}
695
0c14b6c3 696wxFontFamily wxFont::GetFamily() const
489468fe 697{
0c14b6c3 698 wxCHECK_MSG( M_FONTDATA != NULL , wxFONTFAMILY_MAX, wxT("invalid font") );
489468fe
SC
699
700 return M_FONTDATA->GetFamily();
701}
702
0c14b6c3 703wxFontStyle wxFont::GetStyle() const
489468fe 704{
0c14b6c3 705 wxCHECK_MSG( M_FONTDATA != NULL , wxFONTSTYLE_MAX, wxT("invalid font") );
489468fe
SC
706
707 return M_FONTDATA->GetStyle() ;
708}
709
0c14b6c3 710wxFontWeight wxFont::GetWeight() const
489468fe 711{
0c14b6c3 712 wxCHECK_MSG( M_FONTDATA != NULL , wxFONTWEIGHT_MAX, wxT("invalid font") );
489468fe
SC
713
714 return M_FONTDATA->GetWeight();
715}
716
717bool wxFont::GetUnderlined() const
718{
719 wxCHECK_MSG( M_FONTDATA != NULL , false, wxT("invalid font") );
720
721 return M_FONTDATA->GetUnderlined();
722}
723
724wxString wxFont::GetFaceName() const
725{
726 wxCHECK_MSG( M_FONTDATA != NULL , wxEmptyString , wxT("invalid font") );
727
728 return M_FONTDATA->GetFaceName() ;
729}
730
731wxFontEncoding wxFont::GetEncoding() const
732{
733 wxCHECK_MSG( M_FONTDATA != NULL , wxFONTENCODING_DEFAULT , wxT("invalid font") );
734
735 return M_FONTDATA->GetEncoding() ;
736}
737
738bool wxFont::GetNoAntiAliasing() const
739{
740 wxCHECK_MSG( M_FONTDATA != NULL , false, wxT("invalid font") );
741
742 return M_FONTDATA->GetNoAntiAliasing();
743}
744
f1c40652 745#if wxOSX_USE_ATSU_TEXT && wxOSX_USE_CARBON
489468fe
SC
746
747short wxFont::MacGetFontNum() const
748{
749 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
750
f1c40652
SC
751 // cast away constness otherwise lazy font resolution is not possible
752 const_cast<wxFont *>(this)->RealizeResource();
753
754 return M_FONTDATA->m_info.m_qdFontFamily;
489468fe
SC
755}
756
f1c40652 757wxByte wxFont::MacGetFontStyle() const
489468fe
SC
758{
759 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
760
f1c40652
SC
761 // cast away constness otherwise lazy font resolution is not possible
762 const_cast<wxFont *>(this)->RealizeResource();
763
764 return M_FONTDATA->m_info.m_qdFontStyle;
489468fe
SC
765}
766
f1c40652 767wxUint16 wxFont::MacGetThemeFontID() const
489468fe
SC
768{
769 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
770
f1c40652 771 return M_FONTDATA->m_macThemeFontID;
489468fe
SC
772}
773
f1c40652
SC
774#endif
775
beb2638a 776#if wxOSX_USE_ATSU_TEXT
f1c40652 777void * wxFont::MacGetATSUStyle() const
489468fe 778{
f1c40652 779 wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
489468fe 780
f1c40652
SC
781 // cast away constness otherwise lazy font resolution is not possible
782 const_cast<wxFont *>(this)->RealizeResource();
783
784 return M_FONTDATA->m_macATSUStyle;
489468fe 785}
6f283573
SC
786
787#if WXWIN_COMPATIBILITY_2_8
788wxUint32 wxFont::MacGetATSUFontID() const
789{
c22ace4d 790 wxCHECK_MSG( M_FONTDATA != NULL, 0, wxT("invalid font") );
6f283573
SC
791
792 // cast away constness otherwise lazy font resolution is not possible
793 const_cast<wxFont *>(this)->RealizeResource();
794
795 return M_FONTDATA->m_info.m_atsuFontID;
796}
797
798wxUint32 wxFont::MacGetATSUAdditionalQDStyles() const
799{
c22ace4d 800 wxCHECK_MSG( M_FONTDATA != NULL, 0, wxT("invalid font") );
6f283573
SC
801
802 // cast away constness otherwise lazy font resolution is not possible
803 const_cast<wxFont *>(this)->RealizeResource();
804
805 return M_FONTDATA->m_info.m_atsuAdditionalQDStyles;
806}
807#endif
808
f1c40652
SC
809#endif
810
811#if wxOSX_USE_CORE_TEXT
489468fe 812
aa6208d9 813CTFontRef wxFont::OSXGetCTFont() const
489468fe
SC
814{
815 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
816
f1c40652
SC
817 // cast away constness otherwise lazy font resolution is not possible
818 const_cast<wxFont *>(this)->RealizeResource();
819
820 return (CTFontRef)(M_FONTDATA->m_ctFont);
489468fe
SC
821}
822
f1c40652
SC
823#endif
824
9445de1e
SC
825#if wxOSX_USE_COCOA_OR_CARBON
826
aa6208d9 827CGFontRef wxFont::OSXGetCGFont() const
9445de1e
SC
828{
829 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
830
831 // cast away constness otherwise lazy font resolution is not possible
832 const_cast<wxFont *>(this)->RealizeResource();
833
834 return (M_FONTDATA->m_cgFont);
835}
836
837#endif
838
839
f1c40652
SC
840#if wxOSX_USE_COCOA
841
aa6208d9 842NSFont* wxFont::OSXGetNSFont() const
489468fe
SC
843{
844 wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
845
f1c40652
SC
846 // cast away constness otherwise lazy font resolution is not possible
847 const_cast<wxFont *>(this)->RealizeResource();
848
849 return (M_FONTDATA->m_nsFont);
489468fe 850}
f1c40652 851
489468fe
SC
852#endif
853
f1c40652 854const wxNativeFontInfo * wxFont::GetNativeFontInfo() const
489468fe
SC
855{
856 wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
f1c40652 857 wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
489468fe 858
f1c40652
SC
859 // cast away constness otherwise lazy font resolution is not possible
860 const_cast<wxFont *>(this)->RealizeResource();
861
862 // M_FONTDATA->m_info.InitFromFont(*this);
863
864 return &(M_FONTDATA->m_info);
865}
866
867// ----------------------------------------------------------------------------
868// wxNativeFontInfo
869// ----------------------------------------------------------------------------
870
871#if wxOSX_USE_CORE_TEXT
872
873/* from Core Text Manual Common Operations */
874
875static CTFontDescriptorRef wxMacCreateCTFontDescriptor(CFStringRef iFamilyName, CTFontSymbolicTraits iTraits )
876{
877 CTFontDescriptorRef descriptor = NULL;
878 CFMutableDictionaryRef attributes;
879
880 assert(iFamilyName != NULL);
881 // Create a mutable dictionary to hold our attributes.
882 attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
883 &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
884 check(attributes != NULL);
885
886 if (attributes != NULL) {
887 // Add a family name to our attributes.
888 CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, iFamilyName);
889
890
891 if ( iTraits ) {
892 CFMutableDictionaryRef traits;
893 CFNumberRef symTraits;
894
895 // Create the traits dictionary.
896 symTraits = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type,
897 &iTraits);
898 check(symTraits != NULL);
899
900 if (symTraits != NULL) {
901 // Create a dictionary to hold our traits values.
902 traits = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
903 &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
904 check(traits != NULL);
905
906 if (traits != NULL) {
907 // Add the symbolic traits value to the traits dictionary.
908 CFDictionaryAddValue(traits, kCTFontSymbolicTrait, symTraits);
909
910 // Add the traits attribute to our attributes.
911 CFDictionaryAddValue(attributes, kCTFontTraitsAttribute, traits);
912 CFRelease(traits);
913 }
914 CFRelease(symTraits);
915 }
916 }
917 // Create the font descriptor with our attributes
918 descriptor = CTFontDescriptorCreateWithAttributes(attributes);
919 check(descriptor != NULL);
920
921 CFRelease(attributes);
922 }
923 // Return our font descriptor.
924 return descriptor ;
925}
926
927#endif
928
929void wxNativeFontInfo::Init()
930{
931#if wxOSX_USE_CORE_TEXT
932 m_ctFontDescriptor = NULL;
933#endif
934#if wxOSX_USE_ATSU_TEXT
935 m_atsuFontID = 0 ;
936 m_atsuAdditionalQDStyles = 0;
937 m_atsuFontValid = false;
938#if wxOSX_USE_CARBON
939 m_qdFontStyle = 0;
940 m_qdFontFamily = 0;
941#endif
942#endif
943#if wxOSX_USE_COCOA
944 m_nsFontDescriptor = NULL;
f1c40652
SC
945#endif
946 m_pointSize = 0;
947 m_family = wxFONTFAMILY_DEFAULT;
948 m_style = wxFONTSTYLE_NORMAL;
949 m_weight = wxFONTWEIGHT_NORMAL;
950 m_underlined = false;
951 m_faceName.clear();
c443ff6f 952 m_encoding = wxFont::GetDefaultEncoding();
f1c40652
SC
953 m_descriptorValid = false;
954}
955
956#if wxOSX_USE_CORE_TEXT
957void wxNativeFontInfo::Init(CTFontDescriptorRef descr)
958{
959 Init();
960 m_ctFontDescriptor = wxCFRetain(descr);
961
962 wxCFRef< CFNumberRef > sizevalue( (CFNumberRef) CTFontDescriptorCopyAttribute( m_ctFontDescriptor, kCTFontSizeAttribute ) );
963 float fsize;
964 if ( CFNumberGetValue( sizevalue , kCFNumberFloatType , &fsize ) )
965 m_pointSize = (int)( fsize + 0.5 );
966
967 wxCFRef< CFDictionaryRef > traitsvalue( (CFDictionaryRef) CTFontDescriptorCopyAttribute( m_ctFontDescriptor, kCTFontTraitsAttribute ) );
968 CTFontSymbolicTraits traits;
969 if ( CFNumberGetValue((CFNumberRef) CFDictionaryGetValue(traitsvalue,kCTFontSymbolicTrait),kCFNumberIntType,&traits) )
970 {
971 if ( traits & kCTFontItalicTrait )
972 m_style = wxFONTSTYLE_ITALIC;
973 if ( traits & kCTFontBoldTrait )
974 m_weight = wxFONTWEIGHT_BOLD ;
975 }
976
977 wxCFStringRef familyName( (CFStringRef) CTFontDescriptorCopyAttribute(m_ctFontDescriptor, kCTFontFamilyNameAttribute));
978 m_faceName = familyName.AsString();
489468fe
SC
979}
980#endif
981
f1c40652
SC
982void wxNativeFontInfo::EnsureValid()
983{
984 if ( m_descriptorValid )
985 return;
986
292e5e1f 987#if wxOSX_USE_CORE_TEXT
f1c40652
SC
988 if ( m_ctFontDescriptor == NULL && UMAGetSystemVersion() >= 0x1050 )
989 {
990 CTFontSymbolicTraits traits = 0;
991
992 if (m_weight == wxFONTWEIGHT_BOLD)
993 traits |= kCTFontBoldTrait;
994 if (m_style == wxFONTSTYLE_ITALIC || m_style == wxFONTSTYLE_SLANT)
995 traits |= kCTFontItalicTrait;
996
997 // use font caching
998 wxString lookupnameWithSize = wxString::Format( "%s_%ld_%ld", m_faceName.c_str(), traits, m_pointSize );
999
1000 static std::map< std::wstring , wxCFRef< CTFontDescriptorRef > > fontdescriptorcache ;
1001 m_ctFontDescriptor = wxCFRetain((CTFontDescriptorRef)fontdescriptorcache[ std::wstring(lookupnameWithSize.wc_str()) ]);
1002 if ( !m_ctFontDescriptor )
1003 {
1004 // QD selection algorithm is the fastest by orders of magnitude on 10.5
1005 if ( m_faceName.IsAscii() )
1006 {
1007 uint8_t qdstyle = 0;
1008 if (m_weight == wxFONTWEIGHT_BOLD)
1009 qdstyle |= bold;
1010 if (m_style == wxFONTSTYLE_ITALIC || m_style == wxFONTSTYLE_SLANT)
1011 qdstyle |= italic;
1012
1013 Str255 qdFontName ;
1014 wxMacStringToPascal( m_faceName , qdFontName );
1015 wxCFRef< CTFontRef > font;
1016 font.reset( CTFontCreateWithQuickdrawInstance(qdFontName, 0 , qdstyle, m_pointSize) );
1017 m_ctFontDescriptor = CTFontCopyFontDescriptor(font);
1018 }
1019 else
1020 {
1021 m_ctFontDescriptor = wxMacCreateCTFontDescriptor( wxCFStringRef(m_faceName),traits );
1022 }
1023 fontdescriptorcache[ std::wstring(lookupnameWithSize.wc_str()) ].reset(wxCFRetain(m_ctFontDescriptor));
1024 }
1025 }
1026#endif
1027#if wxOSX_USE_ATSU_TEXT
1028 if ( !m_atsuFontValid )
1029 {
9a672c75
SC
1030#if !wxOSX_USE_CARBON
1031 // not needed outside
1032 wxInt16 m_qdFontFamily;
1033 wxInt16 m_qdFontStyle;
1034#endif
f1c40652
SC
1035 wxCFStringRef cf( m_faceName, wxLocale::GetSystemEncoding() );
1036 ATSFontFamilyRef atsfamily = ATSFontFamilyFindFromName( cf , kATSOptionFlagsDefault );
1037 if ( atsfamily == (ATSFontFamilyRef) -1 )
1038 {
1039 wxLogDebug( wxT("ATSFontFamilyFindFromName failed for ") + m_faceName );
1040 m_qdFontFamily = GetAppFont();
1041 }
1042 else
1043 {
1044 m_qdFontFamily = FMGetFontFamilyFromATSFontFamilyRef( atsfamily );
1045 }
1046
1047 m_qdFontStyle = 0;
1048 if (m_weight == wxFONTWEIGHT_BOLD)
1049 m_qdFontStyle |= bold;
1050 if (m_style == wxFONTSTYLE_ITALIC || m_style == wxFONTSTYLE_SLANT)
1051 m_qdFontStyle |= italic;
1052 if (m_underlined)
1053 m_qdFontStyle |= underline;
1054
489468fe 1055
f1c40652
SC
1056 // we try to get as much styles as possible into ATSU
1057
1058 // ATSUFontID and FMFont are equivalent
1059 FMFontStyle intrinsicStyle = 0 ;
1060 OSStatus status = FMGetFontFromFontFamilyInstance( m_qdFontFamily , m_qdFontStyle , (FMFont*)&m_atsuFontID , &intrinsicStyle);
1061 wxASSERT_MSG( status == noErr , wxT("couldn't get an ATSUFont from font family") );
1062 m_atsuAdditionalQDStyles = m_qdFontStyle & (~intrinsicStyle );
1063 m_atsuFontValid = true;
1064 }
1065#endif
1066#if wxOSX_USE_COCOA
1067 if ( m_nsFontDescriptor == NULL )
aa6208d9 1068 OSXValidateNSFontDescriptor();
f1c40652
SC
1069#endif
1070#if wxOSX_USE_IPHONE
1071 // TODO
1072#endif
1073 m_descriptorValid = true;
1074}
1075
1076void wxNativeFontInfo::Init(const wxNativeFontInfo& info)
489468fe 1077{
f1c40652
SC
1078 Init();
1079#if wxOSX_USE_CORE_TEXT
1080 m_ctFontDescriptor = wxCFRetain(info.m_ctFontDescriptor);
1081#endif
1082#if wxOSX_USE_ATSU_TEXT
1083 m_atsuFontValid = info.m_atsuFontValid;
1084 m_atsuFontID = info.m_atsuFontID ;
1085 m_atsuAdditionalQDStyles = info.m_atsuAdditionalQDStyles;
1086#if wxOSX_USE_CARBON
1087 m_qdFontFamily = info.m_qdFontFamily;
1088 m_qdFontStyle = info.m_qdFontStyle;
1089#endif
1090#endif
1091#if wxOSX_USE_COCOA
1092 m_nsFontDescriptor = (NSFontDescriptor*) wxMacCocoaRetain(info.m_nsFontDescriptor);
f1c40652
SC
1093#endif
1094 m_pointSize = info.m_pointSize;
1095 m_family = info.m_family;
1096 m_style = info.m_style;
1097 m_weight = info.m_weight;
1098 m_underlined = info.m_underlined;
1099 m_faceName = info.m_faceName;
1100 m_encoding = info.m_encoding;
1101 m_descriptorValid = info.m_descriptorValid;
1102}
1103
1104void wxNativeFontInfo::Init(int size,
1105 wxFontFamily family,
1106 wxFontStyle style,
1107 wxFontWeight weight,
1108 bool underlined,
1109 const wxString& faceName,
1110 wxFontEncoding encoding)
1111{
1112 Init();
1113 m_pointSize = size;
1114 m_family = family;
1115 m_style = style;
1116 m_weight = weight;
1117 m_underlined = underlined;
1118 m_faceName = faceName;
c443ff6f
SC
1119 if ( encoding == wxFONTENCODING_DEFAULT )
1120 encoding = wxFont::GetDefaultEncoding();
f1c40652 1121 m_encoding = encoding;
489468fe 1122
489468fe
SC
1123}
1124
f1c40652
SC
1125void wxNativeFontInfo::Free()
1126{
1127#if wxOSX_USE_CORE_TEXT
1128 wxCFRelease(m_ctFontDescriptor);
1129 m_ctFontDescriptor = NULL;
1130#endif
1131#if wxOSX_USE_ATSU_TEXT
1132 m_atsuFontID = 0 ;
1133 m_atsuAdditionalQDStyles = 0;
1134 m_atsuFontValid = false;
1135#endif
1136#if wxOSX_USE_COCOA
1137 wxMacCocoaRelease(m_nsFontDescriptor);
1138 m_nsFontDescriptor = NULL;
489468fe 1139#endif
f1c40652
SC
1140 m_descriptorValid = false;
1141}
489468fe 1142
f1c40652 1143bool wxNativeFontInfo::FromString(const wxString& s)
489468fe 1144{
f1c40652 1145 long l;
489468fe 1146
f1c40652 1147 wxStringTokenizer tokenizer(s, _T(";"));
489468fe 1148
f1c40652
SC
1149 wxString token = tokenizer.GetNextToken();
1150 //
1151 // Ignore the version for now
1152 //
1153
1154 token = tokenizer.GetNextToken();
1155 if ( !token.ToLong(&l) )
1156 return false;
1157 m_pointSize = (int)l;
1158
1159 token = tokenizer.GetNextToken();
1160 if ( !token.ToLong(&l) )
1161 return false;
1162 m_family = (wxFontFamily)l;
1163
1164 token = tokenizer.GetNextToken();
1165 if ( !token.ToLong(&l) )
1166 return false;
1167 m_style = (wxFontStyle)l;
1168
1169 token = tokenizer.GetNextToken();
1170 if ( !token.ToLong(&l) )
1171 return false;
1172 m_weight = (wxFontWeight)l;
1173
1174 token = tokenizer.GetNextToken();
1175 if ( !token.ToLong(&l) )
1176 return false;
1177 m_underlined = l != 0;
1178
1179 m_faceName = tokenizer.GetNextToken();
1180
1181#ifndef __WXMAC__
1182 if( !faceName )
1183 return false;
1184#endif
1185
1186 token = tokenizer.GetNextToken();
1187 if ( !token.ToLong(&l) )
1188 return false;
1189 m_encoding = (wxFontEncoding)l;
1190
1191 return true;
1192}
1193
1194wxString wxNativeFontInfo::ToString() const
1195{
1196 wxString s;
1197
1198 s.Printf(_T("%d;%d;%d;%d;%d;%d;%s;%d"),
1199 0, // version
1200 m_pointSize,
1201 m_family,
1202 (int)m_style,
1203 (int)m_weight,
1204 m_underlined,
1205 m_faceName.GetData(),
1206 (int)m_encoding);
1207
1208 return s;
1209}
1210
1211int wxNativeFontInfo::GetPointSize() const
1212{
1213 return m_pointSize;
1214}
1215
1216wxFontStyle wxNativeFontInfo::GetStyle() const
1217{
1218 return m_style;
1219}
1220
1221wxFontWeight wxNativeFontInfo::GetWeight() const
1222{
1223 return m_weight;
1224}
1225
1226bool wxNativeFontInfo::GetUnderlined() const
1227{
1228 return m_underlined;
1229}
1230
1231wxString wxNativeFontInfo::GetFaceName() const
1232{
1233 return m_faceName;
1234}
1235
1236wxFontFamily wxNativeFontInfo::GetFamily() const
1237{
1238 return m_family;
489468fe 1239}
f1c40652
SC
1240
1241wxFontEncoding wxNativeFontInfo::GetEncoding() const
1242{
1243 return m_encoding;
1244}
1245
1246// changing the font descriptor
1247
1248void wxNativeFontInfo::SetPointSize(int pointsize)
1249{
1250 if ( m_pointSize != pointsize )
1251 {
1252 m_pointSize = pointsize;
1253 Free();
1254 }
1255}
1256
1257void wxNativeFontInfo::SetStyle(wxFontStyle style_)
1258{
1259 if ( m_style != style_ )
1260 {
1261 m_style = style_;
1262 Free();
1263 }
1264}
1265
1266void wxNativeFontInfo::SetWeight(wxFontWeight weight_)
1267{
1268 if ( m_weight != weight_ )
1269 {
1270 m_weight = weight_;
1271 Free();
1272 }
1273}
1274
1275void wxNativeFontInfo::SetUnderlined(bool underlined_)
1276{
1277 if ( m_underlined != underlined_ )
1278 {
1279 m_underlined = underlined_;
1280 Free();
1281 }
1282}
1283
1284bool wxNativeFontInfo::SetFaceName(const wxString& facename_)
1285{
1286 if ( m_faceName != facename_ )
1287 {
1288 m_faceName = facename_;
1289 Free();
1290 }
1291 return true;
1292}
1293
1294void wxNativeFontInfo::SetFamily(wxFontFamily family_)
1295{
1296 if ( m_family != family_ )
1297 {
1298 m_family = family_;
1299 Free();
1300 }
1301}
1302
1303void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding_)
1304{
c443ff6f
SC
1305 if ( encoding_ == wxFONTENCODING_DEFAULT )
1306 encoding_ = wxFont::GetDefaultEncoding();
f1c40652
SC
1307 m_encoding = encoding_;
1308 // not reflected in native descriptors
c22ace4d 1309}