+void wxNativeFontInfo::Free()
+{
+#if wxOSX_USE_CORE_TEXT
+ wxCFRelease(m_ctFontDescriptor);
+ m_ctFontDescriptor = NULL;
+#endif
+#if wxOSX_USE_ATSU_TEXT
+ m_atsuFontID = 0 ;
+ m_atsuAdditionalQDStyles = 0;
+ m_atsuFontValid = false;
+#endif
+#if wxOSX_USE_COCOA
+ wxMacCocoaRelease(m_nsFontDescriptor);
+ m_nsFontDescriptor = NULL;
+#endif
+ m_descriptorValid = false;
+}
+
+bool wxNativeFontInfo::FromString(const wxString& s)
+{
+ long l;
+
+ wxStringTokenizer tokenizer(s, wxT(";"));
+
+ wxString token = tokenizer.GetNextToken();
+ //
+ // Ignore the version for now
+ //
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return false;
+ m_pointSize = (int)l;
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return false;
+ m_family = (wxFontFamily)l;
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return false;
+ m_style = (wxFontStyle)l;
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return false;
+ m_weight = (wxFontWeight)l;
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return false;
+ m_underlined = l != 0;
+
+ m_faceName = tokenizer.GetNextToken();
+
+#ifndef __WXMAC__
+ if( !faceName )
+ return false;
+#endif
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return false;
+ m_encoding = (wxFontEncoding)l;
+
+ return true;
+}
+
+wxString wxNativeFontInfo::ToString() const
+{
+ wxString s;
+
+ s.Printf(wxT("%d;%d;%d;%d;%d;%d;%s;%d"),
+ 0, // version
+ m_pointSize,
+ m_family,
+ (int)m_style,
+ (int)m_weight,
+ m_underlined,
+ m_faceName.GetData(),
+ (int)m_encoding);
+
+ return s;
+}
+
+int wxNativeFontInfo::GetPointSize() const
+{
+ return m_pointSize;
+}
+
+wxFontStyle wxNativeFontInfo::GetStyle() const
+{
+ return m_style;
+}
+
+wxFontWeight wxNativeFontInfo::GetWeight() const
+{
+ return m_weight;
+}
+
+bool wxNativeFontInfo::GetUnderlined() const
+{
+ return m_underlined;
+}
+
+wxString wxNativeFontInfo::GetFaceName() const
+{
+ return m_faceName;
+}
+
+wxFontFamily wxNativeFontInfo::GetFamily() const
+{
+ return m_family;
+}
+
+wxFontEncoding wxNativeFontInfo::GetEncoding() const
+{
+ return m_encoding;
+}
+
+// changing the font descriptor
+
+void wxNativeFontInfo::SetPointSize(int pointsize)
+{
+ if ( m_pointSize != pointsize )
+ {
+ m_pointSize = pointsize;
+ Free();
+ }
+}
+
+void wxNativeFontInfo::SetStyle(wxFontStyle style_)
+{
+ if ( m_style != style_ )
+ {
+ m_style = style_;
+ Free();
+ }
+}
+
+void wxNativeFontInfo::SetWeight(wxFontWeight weight_)
+{
+ if ( m_weight != weight_ )
+ {
+ m_weight = weight_;
+ Free();
+ }
+}
+
+void wxNativeFontInfo::SetUnderlined(bool underlined_)
+{
+ if ( m_underlined != underlined_ )
+ {
+ m_underlined = underlined_;
+ Free();
+ }
+}
+
+bool wxNativeFontInfo::SetFaceName(const wxString& facename_)
+{
+ if ( m_faceName != facename_ )
+ {
+ m_faceName = facename_;
+ Free();
+ }
+ return true;
+}
+
+void wxNativeFontInfo::SetFamily(wxFontFamily family_)
+{
+ if ( m_family != family_ )
+ {
+ m_family = family_;
+ Free();
+ }
+}
+
+void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding_)
+{
+ if ( encoding_ == wxFONTENCODING_DEFAULT )
+ encoding_ = wxFont::GetDefaultEncoding();
+ m_encoding = encoding_;
+ // not reflected in native descriptors