X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7c6e85dc647eba193de52f39a5cf8ba89753b2c9..b5a9b87e1620e52f1f13d2619b4677f2b365c93f:/src/msw/font.cpp diff --git a/src/msw/font.cpp b/src/msw/font.cpp index b9a5c35a21..d8d678fe8f 100644 --- a/src/msw/font.cpp +++ b/src/msw/font.cpp @@ -641,10 +641,9 @@ void wxNativeFontInfo::SetFamily(wxFontFamily family) lf.lfPitchAndFamily = (BYTE)(DEFAULT_PITCH) | ff_family; - if ( !wxStrlen(lf.lfFaceName) ) - { - SetFaceName(facename); - } + // reset the facename so that CreateFontIndirect() will automatically choose a + // face name based only on the font family. + lf.lfFaceName[0] = '\0'; } void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding) @@ -678,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(); @@ -750,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; } @@ -777,7 +777,7 @@ wxString wxNativeFontInfo::ToString() const lf.lfClipPrecision, lf.lfQuality, lf.lfPitchAndFamily, - (const wxChar*)lf.lfFaceName); + lf.lfFaceName); return s; }