X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/189e08b45ac97195a4f975fe8507439a8739e5fa..10bd072488691de49910185bea3c7107c77148d1:/src/common/fontcmn.cpp diff --git a/src/common/fontcmn.cpp b/src/common/fontcmn.cpp index c1eec3bd25..7044e66827 100644 --- a/src/common/fontcmn.cpp +++ b/src/common/fontcmn.cpp @@ -32,6 +32,8 @@ #include "wx/font.h" #endif // WX_PRECOMP +#include "wx/fontutil.h" // for wxNativeFontInfo + #include "wx/tokenzr.h" // ============================================================================ @@ -62,22 +64,32 @@ wxFont *wxFontBase::New(const wxNativeFontInfo& info) 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 (wxFont *)NULL; + + return New(fontInfo); +} + +wxNativeFontInfo *wxFontBase::GetNativeFontInfo() const +{ +#if !defined(__WXGTK__) + 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(); + 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 } @@ -94,6 +106,19 @@ void wxFontBase::SetNativeFontInfo(const wxNativeFontInfo& info) #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 ) @@ -213,7 +238,7 @@ wxString wxNativeFontInfo::ToString() const { wxString s; - s.Printf("%d;%d;%d;%d;%d;%s;%d", + s.Printf(_T("%d;%d;%d;%d;%d;%s;%d"), pointSize, family, style, @@ -225,5 +250,5 @@ wxString wxNativeFontInfo::ToString() const return s; } -#endif +#endif // generic wxNativeFontInfo implementation