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