Various wxFont fixes in wxQt

Implement point/pixel size accessors correctly.

Implement support for strike-through fonts.

Also implement DoSetNativeFontInfo() for wxQt.

Make wxFont unit test pass by accounting for Qt-specific aspects.

Closes https://github.com/wxWidgets/wxWidgets/pull/1113
This commit is contained in:
chris2oph
2019-01-09 11:17:23 +00:00
committed by Vadim Zeitlin
parent ebb50551c4
commit dd306cac77
4 changed files with 67 additions and 4 deletions

View File

@@ -135,7 +135,7 @@ public:
if ( info.IsUsingSizeInPixels() )
m_nativeFontInfo.SetPixelSize(info.GetPixelSize());
else
m_nativeFontInfo.SetFractionalPointSize(info.GetFractionalPointSize());
m_nativeFontInfo.SetSizeOrDefault(info.GetFractionalPointSize());
m_nativeFontInfo.SetStyle(info.GetStyle());
m_nativeFontInfo.SetWeight(info.GetWeight());
@@ -236,11 +236,21 @@ bool wxFont::Create(wxSize size, wxFontFamily family, wxFontStyle style,
return true;
}
int wxFont::GetPointSize() const
{
return M_FONTDATA.wxNativeFontInfo::GetPointSize();
}
float wxFont::GetFractionalPointSize() const
{
return M_FONTDATA.GetFractionalPointSize();
}
wxSize wxFont::GetPixelSize() const
{
return M_FONTDATA.GetPixelSize();
}
wxFontStyle wxFont::GetStyle() const
{
return M_FONTDATA.GetStyle();
@@ -271,6 +281,12 @@ const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
return &M_FONTDATA;
}
bool wxFont::GetStrikethrough() const
{
return M_FONTDATA.GetStrikethrough();
}
void wxFont::SetFractionalPointSize(float pointSize)
{
AllocExclusive();
@@ -278,6 +294,13 @@ void wxFont::SetFractionalPointSize(float pointSize)
M_FONTDATA.SetFractionalPointSize(pointSize);
}
void wxFont::SetPixelSize(const wxSize& pixelSize)
{
AllocExclusive();
M_FONTDATA.SetPixelSize(pixelSize);
}
bool wxFont::SetFaceName(const wxString& facename)
{
AllocExclusive();
@@ -313,6 +336,13 @@ void wxFont::SetUnderlined( bool underlined )
M_FONTDATA.SetUnderlined(underlined);
}
void wxFont::SetStrikethrough(bool strikethrough)
{
AllocExclusive();
M_FONTDATA.SetStrikethrough(strikethrough);
}
void wxFont::SetEncoding(wxFontEncoding encoding)
{
AllocExclusive();
@@ -320,6 +350,18 @@ void wxFont::SetEncoding(wxFontEncoding encoding)
M_FONTDATA.SetEncoding(encoding);
}
void wxFont::DoSetNativeFontInfo(const wxNativeFontInfo& info)
{
SetFractionalPointSize(info.GetPointSize());
SetFamily(info.GetFamily());
SetStyle(info.GetStyle());
SetNumericWeight(info.GetWeight());
SetUnderlined(info.GetUnderlined());
SetStrikethrough(info.GetStrikethrough());
SetFaceName(info.GetFaceName());
SetEncoding(info.GetEncoding());
}
wxGDIRefData *wxFont::CreateGDIRefData() const
{
return new wxFontRefData;
@@ -353,6 +395,11 @@ float wxNativeFontInfo::GetFractionalPointSize() const
return m_qtFont.pointSizeF();
}
wxSize wxNativeFontInfo::GetPixelSize() const
{
return wxSize(0, m_qtFont.pixelSize());
}
wxFontStyle wxNativeFontInfo::GetStyle() const
{
switch (m_qtFont.style())