+#if wxMAC_USE_CORE_TEXT || wxMAC_USE_ATSU_TEXT
+ if ( m_macATSUStyle )
+ {
+ ::ATSUDisposeStyle((ATSUStyle)m_macATSUStyle);
+ m_macATSUStyle = NULL ;
+ }
+#endif
+}
+
+void wxFontRefData::MacInvalidateNativeFont()
+{
+#if wxMAC_USE_CORE_TEXT
+ m_ctFont.reset();
+ m_ctFontDescriptor.reset();
+#endif
+#if wxMAC_USE_CORE_TEXT || wxMAC_USE_ATSU_TEXT
+ if ( m_macATSUStyle )
+ {
+ ::ATSUDisposeStyle((ATSUStyle)m_macATSUStyle);
+ m_macATSUStyle = NULL ;
+ }
+#endif
+}
+
+#if wxMAC_USE_CORE_TEXT
+
+/* from Core Text Manual Common Operations */
+
+static CTFontDescriptorRef wxMacCreateCTFontDescriptor(CFStringRef iFamilyName, CTFontSymbolicTraits iTraits )
+{
+ CTFontDescriptorRef descriptor = NULL;
+ CFMutableDictionaryRef attributes;
+
+ assert(iFamilyName != NULL);
+ // Create a mutable dictionary to hold our attributes.
+ attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
+ &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ check(attributes != NULL);
+
+ if (attributes != NULL) {
+ // Add a family name to our attributes.
+ CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, iFamilyName);
+
+
+ if ( iTraits ) {
+ CFMutableDictionaryRef traits;
+ CFNumberRef symTraits;
+
+ // Create the traits dictionary.
+ symTraits = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type,
+ &iTraits);
+ check(symTraits != NULL);
+
+ if (symTraits != NULL) {
+ // Create a dictionary to hold our traits values.
+ traits = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
+ &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ check(traits != NULL);
+
+ if (traits != NULL) {
+ // Add the symbolic traits value to the traits dictionary.
+ CFDictionaryAddValue(traits, kCTFontSymbolicTrait, symTraits);
+
+ // Add the traits attribute to our attributes.
+ CFDictionaryAddValue(attributes, kCTFontTraitsAttribute, traits);
+ CFRelease(traits);
+ }
+ CFRelease(symTraits);
+ }
+ }
+ // Create the font descriptor with our attributes and input size.
+ descriptor = CTFontDescriptorCreateWithAttributes(attributes);
+ check(descriptor != NULL);
+
+ CFRelease(attributes);
+ }
+ // Return our font descriptor.
+ return descriptor ;
+}
+
+wxFontRefData::wxFontRefData( wxUint32 coreTextFontType )
+{
+ CTFontRef font = CTFontCreateUIFontForLanguage( coreTextFontType, 0.0, NULL ) ;
+ if ( CTFontGetSize(m_ctFont) == 0 )
+ {
+ CFRelease(font);
+ font = CTFontCreateUIFontForLanguage( coreTextFontType, 12.0, NULL );
+ }
+ Init( font );
+}
+
+wxFontRefData::wxFontRefData( CTFontRef font )
+{
+ Init( font );
+}
+
+wxFontRefData::wxFontRefData( CTFontDescriptorRef fontdescriptor, int size )
+{
+ if ( size == 0 )
+ {
+ wxCFRef< CFNumberRef > value( (CFNumberRef) CTFontDescriptorCopyAttribute( fontdescriptor, kCTFontSizeAttribute ) );
+
+ float fsize;
+ if ( CFNumberGetValue( value , kCFNumberFloatType , &fsize ) )
+ {
+ size = (int) fsize + 0.5 ;
+ }
+ }
+ Init( CTFontCreateWithFontDescriptor(fontdescriptor, size,NULL) );