+ // QD selection algorithm is the fastest by orders of magnitude on 10.5
+ if ( m_faceName.IsAscii() )
+ {
+ uint8 qdstyle = 0;
+ if (m_weight == wxFONTWEIGHT_BOLD)
+ qdstyle |= bold;
+ if (m_style == wxFONTSTYLE_ITALIC || m_style == wxFONTSTYLE_SLANT)
+ qdstyle |= italic;
+
+ Str255 qdFontName ;
+ wxMacStringToPascal( m_faceName , qdFontName );
+ m_ctFont.reset( CTFontCreateWithQuickdrawInstance(qdFontName, 0 , qdstyle, m_pointSize) );
+ }
+ else
+ {
+
+ static std::map< std::wstring , wxCFRef< CTFontDescriptorRef > > fontdescriptorcache ;
+ wxString lookupname = wxString::Format( "%s_%ld", m_faceName.c_str(), traits );
+ // descriptor caching
+ wxCFRef< CTFontDescriptorRef > descriptor = fontdescriptorcache[ std::wstring(lookupname.wc_str()) ];
+ if ( !descriptor )
+ {
+ wxCFStringRef cf( m_faceName, wxLocale::GetSystemEncoding() );
+ descriptor.reset( wxMacCreateCTFontDescriptor( cf, traits ) );
+ fontdescriptorcache[ std::wstring(lookupname.wc_str()) ] = descriptor;
+ }
+ m_ctFont.reset( CTFontCreateWithFontDescriptor( descriptor, m_pointSize, NULL ) );
+ CTFontSymbolicTraits received = CTFontGetSymbolicTraits( m_ctFont ) & 0x03;
+ if ( traits != received )
+ {
+ // TODO further fallbacks, synthesizing bold and italic, trying direct PostScript names etc
+ }
+ }
+