#include "wx/font.h"
#endif // WX_PRECOMP
+#include "wx/gdicmn.h"
+#include "wx/fontutil.h" // for wxNativeFontInfo
+
#include "wx/tokenzr.h"
// ============================================================================
return new wxFont(info);
}
-wxNativeFontInfo wxFontBase::GetNativeFontInfo() const
+/* static */
+wxFont *wxFontBase::New(const wxString& strNativeFontDesc)
{
-#if !defined(__WXGTK__)
wxNativeFontInfo fontInfo;
+ if ( !fontInfo.FromString(strNativeFontDesc) )
+ return new wxFont(*wxNORMAL_FONT);
- fontInfo.pointSize = GetPointSize();
- fontInfo.family = GetFamily();
- fontInfo.style = GetStyle();
- fontInfo.weight = GetWeight();
- fontInfo.underlined = GetUnderlined();
- fontInfo.faceName = GetFaceName();
- fontInfo.encoding = GetEncoding();
+ return New(fontInfo);
+}
+
+wxNativeFontInfo *wxFontBase::GetNativeFontInfo() const
+{
+#if !defined(__WXGTK__) && !defined(__WXMSW__)
+ wxNativeFontInfo *fontInfo = new wxNativeFontInfo;
+
+ fontInfo->pointSize = GetPointSize();
+ fontInfo->family = GetFamily();
+ fontInfo->style = GetStyle();
+ fontInfo->weight = GetWeight();
+ fontInfo->underlined = GetUnderlined();
+ fontInfo->faceName = GetFaceName();
+ fontInfo->encoding = GetEncoding();
return fontInfo;
#else
- return wxNullNativeFontInfo;
+ return (wxNativeFontInfo *)NULL;
#endif
}
void wxFontBase::SetNativeFontInfo(const wxNativeFontInfo& info)
{
-#if !defined(__WXGTK__)
+#if !defined(__WXGTK__) && !defined(__WXMSW__)
SetPointSize(info.pointSize);
SetFamily(info.family);
SetStyle(info.style);
#endif
}
+wxString wxFontBase::GetNativeFontInfoDesc() const
+{
+ wxString fontDesc;
+ wxNativeFontInfo *fontInfo = GetNativeFontInfo();
+ if ( fontInfo )
+ {
+ fontDesc = fontInfo->ToString();
+ delete fontInfo;
+ }
+
+ return fontDesc;
+}
+
wxFont& wxFont::operator=(const wxFont& font)
{
if ( this != &font )
}
}
-#if !defined(__WXGTK__)
+#if !defined(__WXGTK__) && !defined(__WXMSW__)
// ----------------------------------------------------------------------------
// wxNativeFontInfo
// These are the generic forms of FromString()/ToString.
//
// convert to/from the string representation: format is
-// pointsize;family;style;weight;underlined;facename;encoding
+// version;pointsize;family;style;weight;underlined;facename;encoding
bool wxNativeFontInfo::FromString(const wxString& s)
{
wxStringTokenizer tokenizer(s, _T(";"));
wxString token = tokenizer.GetNextToken();
+ //
+ // Ignore the version for now
+ //
+
+ token = tokenizer.GetNextToken();
if ( !token.ToLong(&l) )
return FALSE;
pointSize = (int)l;
{
wxString s;
- s.Printf("%d;%d;%d;%d;%d;%s;%d",
+ s.Printf(_T("%d;%d;%d;%d;%d;%d;%s;%d"),
+ 0, // version
pointSize,
family,
style,
return s;
}
-#endif
+#endif // generic wxNativeFontInfo implementation