Remove Mac-specific wxFont ctors and fix strikethrough support

Only accept fractional point sizes and numeric weights via wxFont ctor
using wxFontInfo and avoid having specific ctor/Create() overloads for
the different combinations of font properties: this is not portable (as
these ctors don't exist in the other ports) and unsustainable due to the
very real potential of combinatorial explosion as more properties are
added.

As a side-effect, fix support for stricken-through fonts under Mac,
which was broken, by adding the missing wxFontInfo::IsStrikethrough()
call.
This commit is contained in:
Vadim Zeitlin
2018-09-12 19:42:55 +02:00
parent cb8dc4d745
commit 24c83625f6
2 changed files with 19 additions and 46 deletions

View File

@@ -56,17 +56,6 @@ public:
Create(size, family, style, weight, underlined, face, encoding);
}
wxFont(float size,
wxFontFamily family,
wxFontStyle style,
int weight,
bool underlined = false,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
{
Create(size, family, style, weight, underlined, face, encoding);
}
wxFont(const wxSize& pixelSize,
wxFontFamily family,
wxFontStyle style,
@@ -87,14 +76,6 @@ public:
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
bool Create(float size,
wxFontFamily family,
wxFontStyle style,
int weight,
bool underlined = false,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
wxFont(const wxNativeFontInfo& info)
{
(void)Create(info);

View File

@@ -542,13 +542,17 @@ wxFont::wxFont(const wxString& fontdesc)
wxFont::wxFont(const wxFontInfo& info)
{
Create(info.GetFractionalPointSize(),
m_refData = new wxFontRefData
(
info.GetFractionalPointSize(),
info.GetFamily(),
info.GetStyle(),
info.GetNumericWeight(),
info.IsUnderlined(),
info.IsStrikethrough(),
info.GetFaceName(),
info.GetEncoding());
info.GetEncoding()
);
if ( info.IsUsingSizeInPixels() )
SetPixelSize(info.GetPixelSize());
@@ -566,22 +570,6 @@ wxFont::wxFont(int size,
(wxFontWeight)weight, underlined, face, encoding);
}
bool wxFont::Create(float pointSize,
wxFontFamily family,
wxFontStyle style,
int weight,
bool underlined,
const wxString& faceName,
wxFontEncoding encoding)
{
UnRef();
m_refData = new wxFontRefData(pointSize, family, style, weight,
underlined, false, faceName, encoding);
return true;
}
bool wxFont::Create(int pointSize,
wxFontFamily family,
wxFontStyle style,
@@ -592,10 +580,14 @@ bool wxFont::Create(int pointSize,
{
AccountForCompatValues(pointSize, style, weight);
return Create(wxFontInfo::ToFloatPointSize(pointSize),
m_refData = new wxFontRefData
(
wxFontInfo::ToFloatPointSize(pointSize),
family, style,
GetNumericWeightOf(weight),
underlined, faceName, encoding);
underlined, false, faceName, encoding
);
return true;
}
wxFont::~wxFont()