+void wxFont::SetNativeFontInfo(const wxNativeFontInfo& info)
+{
+ Unshare();
+
+ FreeResource();
+
+ M_FONTDATA->Init(info);
+
+ RealizeResource();
+}
+
+// ----------------------------------------------------------------------------
+// accessors
+// ----------------------------------------------------------------------------
+
+int wxFont::GetPointSize() const
+{
+ wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
+
+ return M_FONTDATA->m_pointSize;
+}
+
+int wxFont::GetFamily() const
+{
+ wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
+
+ return M_FONTDATA->m_family;
+}
+
+int wxFont::GetFontId() const
+{
+ wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
+
+ return M_FONTDATA->m_fontId;
+}
+
+int wxFont::GetStyle() const
+{
+ wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
+
+ return M_FONTDATA->m_style;
+}
+
+int wxFont::GetWeight() const
+{
+ wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
+
+ return M_FONTDATA->m_weight;
+}
+
+bool wxFont::GetUnderlined() const
+{
+ wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") );
+
+ return M_FONTDATA->m_underlined;
+}
+
+wxString wxFont::GetFaceName() const
+{
+ wxCHECK_MSG( Ok(), wxT(""), wxT("invalid font") );
+
+ return M_FONTDATA->m_faceName;
+}
+
+wxFontEncoding wxFont::GetEncoding() const
+{
+ wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
+
+ return M_FONTDATA->m_encoding;
+}
+
+// ----------------------------------------------------------------------------
+// wxNativeFontInfo
+// ----------------------------------------------------------------------------
+
+bool wxNativeFontInfo::FromString(const wxString& s)
+{
+ long l;
+
+ wxStringTokenizer tokenizer(s, _T(";"));
+
+ wxString token = tokenizer.GetNextToken();
+ //
+ // Ignore the version for now
+ //
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return FALSE;
+ lf.lfHeight = l;
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return FALSE;
+ lf.lfWidth = l;
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return FALSE;
+ lf.lfEscapement = l;
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return FALSE;
+ lf.lfOrientation = l;
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return FALSE;
+ lf.lfWeight = l;
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return FALSE;
+ lf.lfItalic = (BYTE)l;
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return FALSE;
+ lf.lfUnderline = (BYTE)l;
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return FALSE;
+ lf.lfStrikeOut = (BYTE)l;
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return FALSE;
+ lf.lfCharSet = (BYTE)l;
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return FALSE;
+ lf.lfOutPrecision = (BYTE)l;
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return FALSE;
+ lf.lfClipPrecision = (BYTE)l;
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return FALSE;
+ lf.lfQuality = (BYTE)l;
+
+ token = tokenizer.GetNextToken();
+ if ( !token.ToLong(&l) )
+ return FALSE;
+ lf.lfPitchAndFamily = (BYTE)l;
+
+ token = tokenizer.GetNextToken();
+ if(!token)
+ return FALSE;
+ wxStrcpy(lf.lfFaceName, token.c_str());
+
+ return TRUE;
+}
+
+wxString wxNativeFontInfo::ToString() const
+{
+ wxString s;
+
+ s.Printf(_T("%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%s"),
+ 0, // version, in case we want to change the format later
+ lf.lfHeight,
+ lf.lfWidth,
+ lf.lfEscapement,
+ lf.lfOrientation,
+ lf.lfWeight,
+ lf.lfItalic,
+ lf.lfUnderline,
+ lf.lfStrikeOut,
+ lf.lfCharSet,
+ lf.lfOutPrecision,
+ lf.lfClipPrecision,
+ lf.lfQuality,
+ lf.lfPitchAndFamily,
+ lf.lfFaceName);
+
+ return s;