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