Implement support for numeric weights specified in wxFontInfo

Update the major ports to use wxFontInfo::GetNumericWeight() instead of
GetWeight().
This commit is contained in:
Vadim Zeitlin
2018-09-12 19:13:18 +02:00
parent 23f2929eb4
commit 054c5c4af7
4 changed files with 39 additions and 33 deletions

View File

@@ -36,19 +36,7 @@ public:
// ctors and such // ctors and such
wxFont() { } wxFont() { }
wxFont(const wxFontInfo& info) wxFont(const wxFontInfo& info);
{
Create(info.GetFractionalPointSize(),
info.GetFamily(),
info.GetStyle(),
info.GetWeight(),
info.IsUnderlined(),
info.GetFaceName(),
info.GetEncoding());
if ( info.IsUsingSizeInPixels() )
SetPixelSize(info.GetPixelSize());
}
wxFont( wxOSXSystemFont systemFont ); wxFont( wxOSXSystemFont systemFont );
wxFont(CTFontRef font); wxFont(CTFontRef font);
@@ -71,7 +59,7 @@ public:
wxFont(float size, wxFont(float size,
wxFontFamily family, wxFontFamily family,
wxFontStyle style, wxFontStyle style,
wxFontWeight weight, int weight,
bool underlined = false, bool underlined = false,
const wxString& face = wxEmptyString, const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT) wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
@@ -102,7 +90,7 @@ public:
bool Create(float size, bool Create(float size,
wxFontFamily family, wxFontFamily family,
wxFontStyle style, wxFontStyle style,
wxFontWeight weight, int weight,
bool underlined = false, bool underlined = false,
const wxString& face = wxEmptyString, const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT); wxFontEncoding encoding = wxFONTENCODING_DEFAULT);

View File

@@ -50,7 +50,7 @@ public:
wxFontRefData(float size = -1.0f, wxFontRefData(float size = -1.0f,
wxFontFamily family = wxFONTFAMILY_DEFAULT, wxFontFamily family = wxFONTFAMILY_DEFAULT,
wxFontStyle style = wxFONTSTYLE_NORMAL, wxFontStyle style = wxFONTSTYLE_NORMAL,
wxFontWeight weight = wxFONTWEIGHT_NORMAL, int weight = wxFONTWEIGHT_NORMAL,
bool underlined = false, bool underlined = false,
bool strikethrough = false, bool strikethrough = false,
const wxString& faceName = wxEmptyString, const wxString& faceName = wxEmptyString,
@@ -83,7 +83,7 @@ protected:
void Init(float pointSize, void Init(float pointSize,
wxFontFamily family, wxFontFamily family,
wxFontStyle style, wxFontStyle style,
wxFontWeight weight, int weight,
bool underlined, bool underlined,
bool strikethrough, bool strikethrough,
const wxString& faceName, const wxString& faceName,
@@ -109,7 +109,7 @@ private:
void wxFontRefData::Init(float pointSize, void wxFontRefData::Init(float pointSize,
wxFontFamily family, wxFontFamily family,
wxFontStyle style, wxFontStyle style,
wxFontWeight weight, int weight,
bool underlined, bool underlined,
bool strikethrough, bool strikethrough,
const wxString& faceName, const wxString& faceName,
@@ -138,7 +138,7 @@ void wxFontRefData::Init(float pointSize,
pointSize < 0 ? static_cast<float>(wxDEFAULT_FONT_SIZE) pointSize < 0 ? static_cast<float>(wxDEFAULT_FONT_SIZE)
: pointSize : pointSize
); );
SetWeight( weight ); SetNumericWeight( weight );
SetUnderlined( underlined ); SetUnderlined( underlined );
SetStrikethrough( strikethrough ); SetStrikethrough( strikethrough );
} }
@@ -161,7 +161,7 @@ wxFontRefData::wxFontRefData( const wxFontRefData& data )
} }
wxFontRefData::wxFontRefData(float size, wxFontFamily family, wxFontStyle style, wxFontRefData::wxFontRefData(float size, wxFontFamily family, wxFontStyle style,
wxFontWeight weight, bool underlined, bool strikethrough, int weight, bool underlined, bool strikethrough,
const wxString& faceName, const wxString& faceName,
wxFontEncoding encoding) wxFontEncoding encoding)
{ {
@@ -288,7 +288,7 @@ wxFont::wxFont(const wxFontInfo& info)
m_refData = new wxFontRefData(info.GetFractionalPointSize(), m_refData = new wxFontRefData(info.GetFractionalPointSize(),
info.GetFamily(), info.GetFamily(),
info.GetStyle(), info.GetStyle(),
info.GetWeight(), info.GetNumericWeight(),
info.IsUnderlined(), info.IsUnderlined(),
info.IsStrikethrough(), info.IsStrikethrough(),
info.GetFaceName(), info.GetFaceName(),
@@ -312,7 +312,8 @@ bool wxFont::Create( int pointSize,
AccountForCompatValues(pointSize, style, weight); AccountForCompatValues(pointSize, style, weight);
m_refData = new wxFontRefData(wxFontInfo::ToFloatPointSize(pointSize), m_refData = new wxFontRefData(wxFontInfo::ToFloatPointSize(pointSize),
family, style, weight, family, style,
GetNumericWeightOf(weight),
underlined, false, face, encoding); underlined, false, face, encoding);
return true; return true;

View File

@@ -70,7 +70,7 @@ public:
bool sizeUsingPixels, bool sizeUsingPixels,
wxFontFamily family, wxFontFamily family,
wxFontStyle style, wxFontStyle style,
wxFontWeight weight, int weight,
bool underlined, bool underlined,
bool strikethrough, bool strikethrough,
const wxString& faceName, const wxString& faceName,
@@ -272,7 +272,7 @@ protected:
bool sizeUsingPixels, bool sizeUsingPixels,
wxFontFamily family, wxFontFamily family,
wxFontStyle style, wxFontStyle style,
wxFontWeight weight, int weight,
bool underlined, bool underlined,
bool strikethrough, bool strikethrough,
const wxString& faceName, const wxString& faceName,
@@ -347,7 +347,7 @@ void wxFontRefData::Init(float pointSize,
bool sizeUsingPixels, bool sizeUsingPixels,
wxFontFamily family, wxFontFamily family,
wxFontStyle style, wxFontStyle style,
wxFontWeight weight, int weight,
bool underlined, bool underlined,
bool strikethrough, bool strikethrough,
const wxString& faceName, const wxString& faceName,
@@ -371,7 +371,7 @@ void wxFontRefData::Init(float pointSize,
} }
SetStyle(style); SetStyle(style);
m_nativeFontInfo.SetWeight(weight); SetNumericWeight(weight);
SetUnderlined(underlined); SetUnderlined(underlined);
SetStrikethrough(strikethrough); SetStrikethrough(strikethrough);
@@ -801,7 +801,7 @@ wxFont::wxFont(const wxFontInfo& info)
info.IsUsingSizeInPixels(), info.IsUsingSizeInPixels(),
info.GetFamily(), info.GetFamily(),
info.GetStyle(), info.GetStyle(),
info.GetWeight(), info.GetNumericWeight(),
info.IsUnderlined(), info.IsUnderlined(),
info.IsStrikethrough(), info.IsStrikethrough(),
info.GetFaceName(), info.GetFaceName(),
@@ -833,7 +833,8 @@ bool wxFont::DoCreate(int pointSize,
m_refData = new wxFontRefData(wxFontInfo::ToFloatPointSize(pointSize), m_refData = new wxFontRefData(wxFontInfo::ToFloatPointSize(pointSize),
pixelSize, sizeUsingPixels, pixelSize, sizeUsingPixels,
family, style, weight, family, style,
GetNumericWeightOf(weight),
underlined, false, faceName, encoding); underlined, false, faceName, encoding);
return RealizeResource(); return RealizeResource();

View File

@@ -45,7 +45,7 @@ public:
wxFontRefData(float size, wxFontRefData(float size,
wxFontFamily family, wxFontFamily family,
wxFontStyle style, wxFontStyle style,
wxFontWeight weight, int weight,
bool underlined, bool underlined,
bool strikethrough, bool strikethrough,
const wxString& faceName, const wxString& faceName,
@@ -173,7 +173,7 @@ protected:
void Init(float size, void Init(float size,
wxFontFamily family, wxFontFamily family,
wxFontStyle style, wxFontStyle style,
wxFontWeight weight, int weight,
bool underlined, bool underlined,
bool strikethrough, bool strikethrough,
const wxString& faceName, const wxString& faceName,
@@ -289,7 +289,7 @@ void wxFontRefData::Init()
void wxFontRefData::Init(float size, void wxFontRefData::Init(float size,
wxFontFamily family, wxFontFamily family,
wxFontStyle style, wxFontStyle style,
wxFontWeight weight, int weight,
bool underlined, bool underlined,
bool strikethrough, bool strikethrough,
const wxString& faceName, const wxString& faceName,
@@ -540,6 +540,20 @@ wxFont::wxFont(const wxString& fontdesc)
(void)Create(info); (void)Create(info);
} }
wxFont::wxFont(const wxFontInfo& info)
{
Create(info.GetFractionalPointSize(),
info.GetFamily(),
info.GetStyle(),
info.GetNumericWeight(),
info.IsUnderlined(),
info.GetFaceName(),
info.GetEncoding());
if ( info.IsUsingSizeInPixels() )
SetPixelSize(info.GetPixelSize());
}
wxFont::wxFont(int size, wxFont::wxFont(int size,
int family, int family,
int style, int style,
@@ -555,7 +569,7 @@ wxFont::wxFont(int size,
bool wxFont::Create(float pointSize, bool wxFont::Create(float pointSize,
wxFontFamily family, wxFontFamily family,
wxFontStyle style, wxFontStyle style,
wxFontWeight weight, int weight,
bool underlined, bool underlined,
const wxString& faceName, const wxString& faceName,
wxFontEncoding encoding) wxFontEncoding encoding)
@@ -579,7 +593,9 @@ bool wxFont::Create(int pointSize,
AccountForCompatValues(pointSize, style, weight); AccountForCompatValues(pointSize, style, weight);
return Create(wxFontInfo::ToFloatPointSize(pointSize), return Create(wxFontInfo::ToFloatPointSize(pointSize),
family, style, weight, underlined, faceName, encoding); family, style,
GetNumericWeightOf(weight),
underlined, faceName, encoding);
} }
wxFont::~wxFont() wxFont::~wxFont()