+#if wxOSX_USE_ATSU_TEXT
+void wxFontRefData::CreateATSUFont()
+{
+ // we try to get as much styles as possible into ATSU
+
+ OSStatus status = ::ATSUCreateStyle(&m_macATSUStyle);
+ wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") );
+
+ ATSUAttributeTag atsuTags[] =
+ {
+ kATSUFontTag ,
+ kATSUSizeTag ,
+ kATSUVerticalCharacterTag,
+ kATSUQDBoldfaceTag ,
+ kATSUQDItalicTag ,
+ kATSUQDUnderlineTag ,
+ kATSUQDCondensedTag ,
+ kATSUQDExtendedTag ,
+ };
+ ByteCount atsuSizes[WXSIZEOF(atsuTags)] =
+ {
+ 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_info.m_pointSize );
+ ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
+ FMFontStyle addQDStyle = m_info.m_atsuAdditionalQDStyles;
+ ATSUAttributeValuePtr atsuValues[WXSIZEOF(atsuTags)] =
+ {
+ &m_info.m_atsuFontID ,
+ &atsuSize ,
+ &kHorizontal,
+ (addQDStyle & bold) ? &kTrue : &kFalse ,
+ (addQDStyle & italic) ? &kTrue : &kFalse ,
+ (addQDStyle & underline) ? &kTrue : &kFalse ,
+ (addQDStyle & condense) ? &kTrue : &kFalse ,
+ (addQDStyle & extend) ? &kTrue : &kFalse ,
+ };
+
+ status = ::ATSUSetAttributes(
+ (ATSUStyle)m_macATSUStyle,
+ WXSIZEOF(atsuTags),
+ atsuTags, atsuSizes, atsuValues);
+
+ wxASSERT_MSG( status == noErr , wxString::Format(wxT("couldn't modify ATSU style. Status was %d"), (int) status).c_str() );
+
+ if ( m_cgFont.get() == NULL )
+ {
+ ATSFontRef fontRef = FMGetATSFontRefFromFont(m_info.m_atsuFontID);
+ m_cgFont.reset( CGFontCreateWithPlatformFont( &fontRef ) );
+ }
+}
+#endif
+
+static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; }
+static const CGAffineTransform kSlantTransform = CGAffineTransformMake( 1, 0, tan(DegToRad(11)), 1, 0, 0 );
+