+ OSStatus status = noErr;
+ Str255 qdFontName ;
+ if ( m_macThemeFontID != kThemeCurrentPortFont )
+ {
+ Style style ;
+ GetThemeFont( m_macThemeFontID, GetApplicationScript(), qdFontName, &m_macFontSize, &style );
+ if ( m_macFontSize == 0 )
+ m_macFontSize = 12;
+ m_macFontStyle = style ;
+ m_faceName = wxMacMakeStringFromPascal( qdFontName );
+ if ( m_macFontStyle & bold )
+ m_weight = wxBOLD ;
+ else
+ m_weight = wxNORMAL ;
+ if ( m_macFontStyle & italic )
+ m_style = wxITALIC ;
+ if ( m_macFontStyle & underline )
+ m_underlined = true ;
+ m_pointSize = m_macFontSize ;
+ m_macFontFamily = FMGetFontFamilyFromName( qdFontName );
+ }
+ else
+ {
+ if ( m_faceName.empty() )
+ {
+ if ( m_family == wxDEFAULT )
+ {
+ m_macFontFamily = GetAppFont();
+ FMGetFontFamilyName(m_macFontFamily,qdFontName);
+ m_faceName = wxMacMakeStringFromPascal( qdFontName );
+ }
+ else
+ {
+ switch ( m_family )
+ {
+ case wxSCRIPT :
+ case wxROMAN :
+ case wxDECORATIVE :
+ m_faceName = wxT("Times");
+ break ;
+
+ case wxSWISS :
+ m_faceName = wxT("Lucida Grande");
+ break ;
+
+ case wxMODERN :
+ case wxTELETYPE:
+ m_faceName = wxT("Monaco");
+ break ;
+
+ default:
+ m_faceName = wxT("Times");
+ break ;
+ }
+ wxMacStringToPascal( m_faceName , qdFontName );
+ m_macFontFamily = FMGetFontFamilyFromName( qdFontName );
+ if ( m_macFontFamily == kInvalidFontFamily )
+ {
+ wxLogDebug( wxT("ATSFontFamilyFindFromName failed for %s"), m_faceName.c_str() );
+ m_macFontFamily = GetAppFont();
+ }
+ }
+ }
+ else
+ {
+ if ( m_faceName == wxT("systemfont") )
+ m_macFontFamily = GetSysFont();
+ else if ( m_faceName == wxT("applicationfont") )
+ m_macFontFamily = GetAppFont();
+ else
+ {
+ wxMacCFStringHolder cf( m_faceName, wxLocale::GetSystemEncoding() );
+ ATSFontFamilyRef atsfamily = ATSFontFamilyFindFromName( cf , kATSOptionFlagsDefault );
+ if ( atsfamily == (ATSFontFamilyRef) -1 )
+ {
+ wxLogDebug( wxT("ATSFontFamilyFindFromName failed for ") + m_faceName );
+ m_macFontFamily = GetAppFont();
+ }
+ else
+ m_macFontFamily = FMGetFontFamilyFromATSFontFamilyRef( atsfamily );
+ }
+ }
+
+ m_macFontStyle = 0;
+ if (m_weight == wxBOLD)
+ m_macFontStyle |= bold;
+ if (m_style == wxITALIC || m_style == wxSLANT)
+ m_macFontStyle |= italic;
+ if (m_underlined)
+ m_macFontStyle |= underline;
+ m_macFontSize = m_pointSize ;
+ }
+
+ // we try to get as much styles as possible into ATSU
+
+
+ // ATSUFontID and FMFont are equivalent
+ FMFontStyle intrinsicStyle = 0 ;
+ status = FMGetFontFromFontFamilyInstance( m_macFontFamily , m_macFontStyle , &m_macATSUFontID , &intrinsicStyle);
+ wxASSERT_MSG( status == noErr , wxT("couldn't get an ATSUFont from font family") );
+ m_macATSUAdditionalQDStyles = m_macFontStyle & (~intrinsicStyle );
+
+ if ( m_macATSUStyle )
+ {
+ ::ATSUDisposeStyle((ATSUStyle)m_macATSUStyle);
+ m_macATSUStyle = NULL ;
+ }
+
+ status = ::ATSUCreateStyle((ATSUStyle *)&m_macATSUStyle);
+ wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") );
+
+ ATSUAttributeTag atsuTags[] =
+ {