- ::GetFNum( (StringPtr) 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 ;
-
- //TODO:if we supply the style as an additional parameter we must make a testing
- //sequence in order to degrade gracefully while trying to maintain most of the style
- //information, meanwhile we just take the normal font and apply the features after
- OSStatus status = ::ATSUFONDtoFontID(m_macFontNum, normal /*qdStyle*/, (UInt32*)&m_macATSUFontID);
- wxASSERT_MSG( status == noErr , "couldn't retrieve font identifier" ) ;
+ 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") ) ;