Centralize backwards compatibility code in wxFont
Add wxFontBase::AccountForCompatValues() and use it in all ports instead of redoing the same comparison with wxDEFAULT in all of them. This is done not so much to avoid the code duplication, which was minimal anyhow, but to make the code more clear and make it easier to remove it from all ports at once in the bright (but remote) future when we don't need these compatibility hacks any more. Also document that wxDEFAULT and wxNORMAL are only handled specially in the old-style ctor taking the individual font components and not the new one using wxFontInfo and extend the unit test to check this.
This commit is contained in:
@@ -187,6 +187,9 @@ bool wxFont::Create(wxSize size, wxFontFamily family, wxFontStyle style,
|
||||
wxFontWeight weight, bool underlined, const wxString& face,
|
||||
wxFontEncoding WXUNUSED(encoding) )
|
||||
{
|
||||
int pointSize = size.GetHeight();
|
||||
AccountForCompatValues(pointSize, style, weight);
|
||||
|
||||
if (!face.empty())
|
||||
M_FONTDATA.SetFaceName(face);
|
||||
else
|
||||
@@ -195,7 +198,7 @@ bool wxFont::Create(wxSize size, wxFontFamily family, wxFontStyle style,
|
||||
M_FONTDATA.SetStyle(style);
|
||||
M_FONTDATA.SetWeight(weight);
|
||||
M_FONTDATA.SetUnderlined(underlined);
|
||||
M_FONTDATA.SetPointSize(size.GetHeight());
|
||||
M_FONTDATA.SetPointSize(pointSize);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user