Parse legacy weight in string font descriptions

Preserve compatiblity font descriptions serialized using
wxNativeFontInfo::ToString() in older versions of wxWidgets and load
them correctly, instead of asserting.

aedf89b098 originally did this, then
d355af3420 reversed it as "not needed".
Turns out it is, for old serializations.

Reverse d355af3420 and implement the same
backward compatible logic in wxOSX. wxMSW uses win32-native description
and doesn't need this.
This commit is contained in:
Václav Slavík
2018-09-21 11:33:41 +02:00
committed by Václav Slavík
parent ac6766c2fc
commit 1cf981e243
2 changed files with 3 additions and 3 deletions

View File

@@ -776,9 +776,9 @@ bool wxNativeFontInfo::FromString(const wxString& s)
token = tokenizer.GetNextToken();
if ( !token.ToLong(&l) )
return false;
if ( l <= wxFONTWEIGHT_INVALID || l > wxFONTWEIGHT_MAX )
weight = wxFont::ConvertFromLegacyWeightIfNecessary(l);
if ( weight <= wxFONTWEIGHT_INVALID || weight > wxFONTWEIGHT_MAX )
return false;
weight = static_cast<int>(l);
token = tokenizer.GetNextToken();
if ( !token.ToLong(&l) )

View File

@@ -929,7 +929,7 @@ bool wxNativeFontInfo::FromString(const wxString& s)
token = tokenizer.GetNextToken();
if ( !token.ToLong(&l) )
return false;
m_ctWeight = WXWeightToCT(l);
m_ctWeight = WXWeightToCT(wxFont::ConvertFromLegacyWeightIfNecessary(l));
token = tokenizer.GetNextToken();
if ( !token.ToLong(&l) )