- 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
-#ifdef __WXDEBUG__
- OSStatus status =
-#endif // __WXDEBUG__
- ::ATSUFONDtoFontID(m_macFontNum, normal /*qdStyle*/, (UInt32*)&m_macATSUFontID);
- /*
- status = ATSUFindFontFromName ( (Ptr) m_faceName , strlen( m_faceName ) ,
- kFontFullName, kFontMacintoshPlatform, kFontRomanScript , kFontNoLanguage , (UInt32*)&m_macATSUFontID ) ;
- */
- wxASSERT_MSG( status == noErr , wxT("couldn't retrieve font identifier") ) ;
+ // 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[] =
+ {
+ 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 ;
+
+ Fixed atsuSize = IntToFixed( m_macFontSize );
+ 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") );