]> git.saurik.com Git - wxWidgets.git/commitdiff
deal with fonts with empty face name correctly in wxNativeFontInfo::FromString()...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 17 May 2009 11:48:48 +0000 (11:48 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 17 May 2009 11:48:48 +0000 (11:48 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60673 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/font.cpp

index b83bb2288c048797067f0c03dd9e3dbf96556e3d..d8d678fe8fe54f66d82093530f343378d44f10d5 100644 (file)
@@ -677,7 +677,7 @@ bool wxNativeFontInfo::FromString(const wxString& s)
 {
     long l;
 
-    wxStringTokenizer tokenizer(s, wxS(";"));
+    wxStringTokenizer tokenizer(s, wxS(";"), wxTOKEN_RET_EMPTY_ALL);
 
     // first the version
     wxString token = tokenizer.GetNextToken();
@@ -749,10 +749,11 @@ bool wxNativeFontInfo::FromString(const wxString& s)
         return false;
     lf.lfPitchAndFamily = (BYTE)l;
 
-    token = tokenizer.GetNextToken();
-    if(!token)
+    if ( !tokenizer.HasMoreTokens() )
         return false;
-    wxStrcpy(lf.lfFaceName, token.c_str());
+
+    // the face name may be empty
+    wxStrcpy(lf.lfFaceName, tokenizer.GetNextToken());
 
     return true;
 }
@@ -776,7 +777,7 @@ wxString wxNativeFontInfo::ToString() const
              lf.lfClipPrecision,
              lf.lfQuality,
              lf.lfPitchAndFamily,
-             (const wxChar*)lf.lfFaceName);
+             lf.lfFaceName);
 
     return s;
 }