- if( m_faceName == "" )
- {
- switch( m_family )
- {
- case wxDEFAULT :
- m_macFontNum = ::GetAppFont() ;
- break ;
- case wxDECORATIVE :
- ::GetFNum( "\pTimes" , &m_macFontNum) ;
- break ;
- case wxROMAN :
- ::GetFNum( "\pTimes" , &m_macFontNum) ;
- break ;
- case wxSCRIPT :
- ::GetFNum( "\pTimes" , &m_macFontNum) ;
- break ;
- case wxSWISS :
- ::GetFNum( "\pHelvetica" , &m_macFontNum) ;
- break ;
- case wxMODERN :
- ::GetFNum( "\pMonaco" , &m_macFontNum) ;
- break ;
- }
- }
- else
- {
- if ( m_faceName == "systemfont" )
- m_macFontNum = ::GetSysFont() ;
- else if ( m_faceName == "applicationfont" )
- m_macFontNum = ::GetAppFont() ;
- else
- {
- strcpy(wxBuffer, m_faceName);
- C2PStr(wxBuffer);
- ::GetFNum( (unsigned char*) wxBuffer, &m_macFontNum);
- }
- }
-
- 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 ;
-}
-
-wxFont::wxFont()
-{
- if ( wxTheFontList )
- wxTheFontList->Append(this);
-}
-
-wxFont::wxFont(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName)
-{
- Create(pointSize, family, style, weight, underlined, faceName);
-
- if ( wxTheFontList )
- wxTheFontList->Append(this);
-}
-
-bool wxFont::Create(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName)
+ if ( m_macThemeFontID != kThemeCurrentPortFont )
+ {
+ Str255 fontName ;
+ GetThemeFont(m_macThemeFontID , GetApplicationScript() , fontName , &m_macFontSize , &m_macFontStyle ) ;
+ m_faceName = wxMacMakeStringFromPascal( fontName ) ;
+ 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 ;
+ ::GetFNum( fontName, &m_macFontNum);
+ m_pointSize = m_macFontSize ;
+ }
+ else
+ {
+ if( m_faceName.Length() == 0 )
+ {
+ switch( m_family )
+ {
+ case wxDEFAULT :
+ m_macFontNum = ::GetAppFont() ;
+ break ;
+ case wxSCRIPT :
+ case wxROMAN :
+ case wxDECORATIVE :
+#ifdef __WXMAC_OSX__
+ ::GetFNum( "\pTimes" , &m_macFontNum) ;
+#else
+ ::GetFNum( "\pTimes" , &m_macFontNum) ;
+#endif
+ break ;
+ case wxSWISS :
+#ifdef __WXMAC_OSX__
+ ::GetFNum( "\pLucida Grande" , &m_macFontNum) ;
+#else
+ ::GetFNum( "\pGeneva" , &m_macFontNum) ;
+#endif
+ break ;
+ case wxMODERN :
+#ifdef __WXMAC_OSX__
+ ::GetFNum( "\pMonaco" , &m_macFontNum) ;
+#else
+ ::GetFNum( "\pMonaco" , &m_macFontNum) ;
+#endif
+ break ;
+ }
+ Str255 name ;
+ ::GetFontName( m_macFontNum , name ) ;
+ m_faceName = wxMacMakeStringFromPascal( name ) ;
+ }
+ else
+ {
+ if ( m_faceName == wxT("systemfont") )
+ m_macFontNum = ::GetSysFont() ;
+ else if ( m_faceName == wxT("applicationfont") )
+ m_macFontNum = ::GetAppFont() ;
+ else
+ {
+ Str255 fontname ;
+ wxMacStringToPascal( m_faceName , fontname ) ;
+ ::GetFNum( fontname, &m_macFontNum);
+ }
+ }
+
+ 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
+
+ Fixed atsuSize = IntToFixed( m_macFontSize ) ;
+
+ Style atsuStyle = normal ;
+ verify_noerr(::ATSUFONDtoFontID(m_macFontNum, atsuStyle , (UInt32*)&m_macATSUFontID) );
+ if ( m_macFontStyle & bold )
+ {
+ ATSUFontID test ;
+ if ( ::ATSUFONDtoFontID(m_macFontNum, atsuStyle | bold , &test) == noErr )
+ {
+ atsuStyle |= bold ;
+ m_macATSUFontID = test ;
+ }
+ }
+ if ( m_macFontStyle & italic )
+ {
+ ATSUFontID test ;
+ if ( ::ATSUFONDtoFontID(m_macFontNum, atsuStyle | italic , &test) == noErr )
+ {
+ atsuStyle |= italic ;
+ m_macATSUFontID = test ;
+ }
+ }
+ if ( m_macFontStyle & underline )
+ {
+ ATSUFontID test ;
+ if ( ::ATSUFONDtoFontID(m_macFontNum, atsuStyle | underline , &test) == noErr )
+ {
+ atsuStyle |= underline ;
+ m_macATSUFontID = test ;
+ }
+ }
+
+ m_macATSUAdditionalQDStyles = m_macFontStyle & (~atsuStyle ) ;
+
+ if ( m_macATSUStyle )
+ {
+ ::ATSUDisposeStyle((ATSUStyle)m_macATSUStyle);
+ m_macATSUStyle = NULL ;
+ }
+ OSStatus status = ::ATSUCreateStyle((ATSUStyle *)&m_macATSUStyle) ;
+ wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") ) ;
+ ATSUAttributeTag atsuTags[] =
+ {
+ kATSUFontTag ,
+ kATSUSizeTag ,
+ kATSUVerticalCharacterTag,
+ kATSUQDBoldfaceTag ,
+ kATSUQDItalicTag ,
+ kATSUQDUnderlineTag ,
+ kATSUQDCondensedTag ,
+ kATSUQDExtendedTag ,
+ } ;
+ ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
+ {
+ sizeof( ATSUFontID ) ,
+ sizeof( Fixed ) ,
+ sizeof( ATSUVerticalCharacterType),
+ sizeof( Boolean ) ,
+ sizeof( Boolean ) ,
+ sizeof( Boolean ) ,
+ sizeof( Boolean ) ,
+ sizeof( Boolean ) ,
+ } ;
+ Boolean kTrue = true ;
+ Boolean kFalse = false ;
+
+ ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
+ ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
+ {
+ &m_macATSUFontID ,
+ &atsuSize ,
+ &kHorizontal,
+ (m_macATSUAdditionalQDStyles & bold) ? &kTrue : &kFalse ,
+ (m_macATSUAdditionalQDStyles & italic) ? &kTrue : &kFalse ,
+ (m_macATSUAdditionalQDStyles & underline) ? &kTrue : &kFalse ,
+ (m_macATSUAdditionalQDStyles & condense) ? &kTrue : &kFalse ,
+ (m_macATSUAdditionalQDStyles & extend) ? &kTrue : &kFalse ,
+ } ;
+ status = ::ATSUSetAttributes((ATSUStyle)m_macATSUStyle, sizeof(atsuTags)/sizeof(ATSUAttributeTag) ,
+ atsuTags, atsuSizes, atsuValues);
+
+ wxASSERT_MSG( status == noErr , wxT("couldn't Modify ATSU style") ) ;
+}
+
+// ----------------------------------------------------------------------------
+// wxFont
+// ----------------------------------------------------------------------------
+
+void wxFont::Init()
+{
+}
+
+bool wxFont::Create(const wxNativeFontInfo& info)
+{
+ return Create(info.pointSize, info.family, info.style, info.weight,
+ info.underlined, info.faceName, info.encoding);
+}
+
+wxFont::wxFont(const wxString& fontdesc)
+{
+ wxNativeFontInfo info;
+ if ( info.FromString(fontdesc) )
+ (void)Create(info);
+}
+
+bool wxFont::Create(int pointSize,
+ int family,
+ int style,
+ int weight,
+ bool underlined,
+ const wxString& faceName,
+ wxFontEncoding encoding)