+ // cast away constness otherwise lazy font resolution is not possible
+ const_cast<wxFont *>(this)->RealizeResource();
+
+ // M_FONTDATA->m_info.InitFromFont(*this);
+
+ return &(M_FONTDATA->m_info);
+}
+
+// ----------------------------------------------------------------------------
+// wxNativeFontInfo
+// ----------------------------------------------------------------------------
+
+#if wxOSX_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
+ descriptor = CTFontDescriptorCreateWithAttributes(attributes);
+ check(descriptor != NULL);
+
+ CFRelease(attributes);
+ }
+ // Return our font descriptor.
+ return descriptor ;
+}
+
+#endif
+
+void wxNativeFontInfo::Init()
+{
+#if wxOSX_USE_CORE_TEXT
+ m_ctFontDescriptor = NULL;
+#endif
+#if wxOSX_USE_ATSU_TEXT
+ m_atsuFontID = 0 ;
+ m_atsuAdditionalQDStyles = 0;
+ m_atsuFontValid = false;
+#if wxOSX_USE_CARBON
+ m_qdFontStyle = 0;
+ m_qdFontFamily = 0;
+#endif
+#endif
+#if wxOSX_USE_COCOA
+ m_nsFontDescriptor = NULL;
+#endif
+#if wxOSX_USE_IPHONE
+ m_uiFontDescriptor = NULL;
+#endif
+ m_pointSize = 0;
+ m_family = wxFONTFAMILY_DEFAULT;
+ m_style = wxFONTSTYLE_NORMAL;
+ m_weight = wxFONTWEIGHT_NORMAL;
+ m_underlined = false;
+ m_faceName.clear();
+ m_encoding = wxFONTENCODING_DEFAULT;
+ m_descriptorValid = false;
+}
+
+#if wxOSX_USE_CORE_TEXT
+void wxNativeFontInfo::Init(CTFontDescriptorRef descr)
+{
+ Init();
+ m_ctFontDescriptor = wxCFRetain(descr);
+
+ wxCFRef< CFNumberRef > sizevalue( (CFNumberRef) CTFontDescriptorCopyAttribute( m_ctFontDescriptor, kCTFontSizeAttribute ) );
+ float fsize;
+ if ( CFNumberGetValue( sizevalue , kCFNumberFloatType , &fsize ) )
+ m_pointSize = (int)( fsize + 0.5 );
+
+ wxCFRef< CFDictionaryRef > traitsvalue( (CFDictionaryRef) CTFontDescriptorCopyAttribute( m_ctFontDescriptor, kCTFontTraitsAttribute ) );
+ CTFontSymbolicTraits traits;
+ if ( CFNumberGetValue((CFNumberRef) CFDictionaryGetValue(traitsvalue,kCTFontSymbolicTrait),kCFNumberIntType,&traits) )
+ {
+ if ( traits & kCTFontItalicTrait )
+ m_style = wxFONTSTYLE_ITALIC;
+ if ( traits & kCTFontBoldTrait )
+ m_weight = wxFONTWEIGHT_BOLD ;
+ }
+
+ wxCFStringRef familyName( (CFStringRef) CTFontDescriptorCopyAttribute(m_ctFontDescriptor, kCTFontFamilyNameAttribute));
+ m_faceName = familyName.AsString();