From 4e0b4e593960292c71c850b51c4abd85ca1678b7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 7 Sep 2018 02:30:52 +0200 Subject: [PATCH] Fix wxDFB build after the font changes Implement the new wxFont pure virtual methods in this port version of this class. Neither arbitrary weights nor fractional point sizes are actually supported in this port however. --- include/wx/dfb/font.h | 8 ++++---- include/wx/private/fontmgr.h | 10 +++++----- src/common/fontmgrcmn.cpp | 10 +++++----- src/dfb/font.cpp | 26 ++++++++++++++++---------- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/include/wx/dfb/font.h b/include/wx/dfb/font.h index 83e286353a..d5f67e9f22 100644 --- a/include/wx/dfb/font.h +++ b/include/wx/dfb/font.h @@ -72,19 +72,19 @@ public: bool Create(const wxNativeFontInfo& fontinfo); // implement base class pure virtuals - virtual int GetPointSize() const; + virtual float GetFractionalPointSize() const; virtual wxFontStyle GetStyle() const; - virtual wxFontWeight GetWeight() const; + virtual int GetNumericWeight() const; virtual wxString GetFaceName() const; virtual bool GetUnderlined() const; virtual wxFontEncoding GetEncoding() const; virtual bool IsFixedWidth() const; virtual const wxNativeFontInfo *GetNativeFontInfo() const; - virtual void SetPointSize(int pointSize); + virtual void SetFractionalPointSize(float pointSize); virtual void SetFamily(wxFontFamily family); virtual void SetStyle(wxFontStyle style); - virtual void SetWeight(wxFontWeight weight); + virtual void SetNumericWeight(int weight); virtual bool SetFaceName(const wxString& faceName); virtual void SetUnderlined(bool underlined); virtual void SetEncoding(wxFontEncoding encoding); diff --git a/include/wx/private/fontmgr.h b/include/wx/private/fontmgr.h index 76f2210f6e..c14463add4 100644 --- a/include/wx/private/fontmgr.h +++ b/include/wx/private/fontmgr.h @@ -204,7 +204,7 @@ public: wxFontMgrFontRefData(int size = wxDEFAULT, wxFontFamily family = wxFONTFAMILY_DEFAULT, wxFontStyle style = wxFONTSTYLE_NORMAL, - wxFontWeight weight = wxFONTWEIGHT_NORMAL, + int weight = wxFONTWEIGHT_NORMAL, bool underlined = false, const wxString& faceName = wxEmptyString, wxFontEncoding encoding = wxFONTENCODING_DEFAULT); @@ -218,18 +218,18 @@ public: const wxNativeFontInfo *GetNativeFontInfo() const { return &m_info; } - int GetPointSize() const { return m_info.pointSize; } + float GetFractionalPointSize() const { return m_info.pointSize; } wxString GetFaceName() const { return m_info.faceName; } wxFontFamily GetFamily() const { return m_info.family; } wxFontStyle GetStyle() const { return m_info.style; } - wxFontWeight GetWeight() const { return m_info.weight; } + int GetNumericWeight() const { return m_info.weight; } bool GetUnderlined() const { return m_info.underlined; } wxFontEncoding GetEncoding() const { return m_info.encoding; } - void SetPointSize(int pointSize); + void SetFractionalPointSize(float pointSize); void SetFamily(wxFontFamily family); void SetStyle(wxFontStyle style); - void SetWeight(wxFontWeight weight); + void SetNumericWeight(int weight); void SetFaceName(const wxString& faceName); void SetUnderlined(bool underlined); void SetEncoding(wxFontEncoding encoding); diff --git a/src/common/fontmgrcmn.cpp b/src/common/fontmgrcmn.cpp index 1559d0ad7d..39fc9e4ac5 100644 --- a/src/common/fontmgrcmn.cpp +++ b/src/common/fontmgrcmn.cpp @@ -118,7 +118,7 @@ wxFontBundleBase::GetFaceForFont(const wxFontMgrFontRefData& font) const int type = FaceType_Regular; - if ( font.GetWeight() == wxFONTWEIGHT_BOLD ) + if ( font.GetNumericWeight() >= wxFONTWEIGHT_BOLD ) type |= FaceType_Bold; // FIXME -- this should read "if ( font->GetStyle() == wxFONTSTYLE_ITALIC )", @@ -227,7 +227,7 @@ void wxFontsManagerBase::AddBundle(wxFontBundle *bundle) wxFontMgrFontRefData::wxFontMgrFontRefData(int size, wxFontFamily family, wxFontStyle style, - wxFontWeight weight, + int weight, bool underlined, const wxString& faceName, wxFontEncoding encoding) @@ -240,7 +240,7 @@ wxFontMgrFontRefData::wxFontMgrFontRefData(int size, m_info.family = (wxFontFamily)family; m_info.faceName = faceName; m_info.style = (wxFontStyle)style; - m_info.weight = (wxFontWeight)weight; + m_info.weight = weight; m_info.pointSize = size; m_info.underlined = underlined; m_info.encoding = encoding; @@ -281,7 +281,7 @@ wxFontMgrFontRefData::GetFontInstance(float scale, bool antialiased) const antialiased); } -void wxFontMgrFontRefData::SetPointSize(int pointSize) +void wxFontMgrFontRefData::SetFractionalPointSize(float pointSize) { m_info.pointSize = pointSize; m_fontValid = false; @@ -299,7 +299,7 @@ void wxFontMgrFontRefData::SetStyle(wxFontStyle style) m_fontValid = false; } -void wxFontMgrFontRefData::SetWeight(wxFontWeight weight) +void wxFontMgrFontRefData::SetNumericWeight(int weight) { m_info.weight = weight; m_fontValid = false; diff --git a/src/dfb/font.cpp b/src/dfb/font.cpp index 0f154560f8..f55c558838 100644 --- a/src/dfb/font.cpp +++ b/src/dfb/font.cpp @@ -40,8 +40,14 @@ typedef wxFontMgrFontRefData wxFontRefData; bool wxFont::Create(const wxNativeFontInfo& info) { - return Create(info.pointSize, info.family, info.style, info.weight, - info.underlined, info.faceName, info.encoding); + m_refData = new wxFontRefData(info.pointSize, + info.family, + info.style, + info.weight, + info.underlined, + info.faceName, + info.encoding); + return true; } bool wxFont::Create(int pointSize, @@ -81,11 +87,11 @@ wxIDirectFBFontPtr wxFont::GetDirectFBFont(bool antialiased) const return i ? i->GetDirectFBFont() : wxIDirectFBFontPtr(); } -int wxFont::GetPointSize() const +float wxFont::GetFractionalPointSize() const { wxCHECK_MSG( IsOk(), 0, wxT("invalid font") ); - return M_FONTDATA->GetPointSize(); + return M_FONTDATA->GetFractionalPointSize(); } wxString wxFont::GetFaceName() const @@ -107,11 +113,11 @@ wxFontStyle wxFont::GetStyle() const return M_FONTDATA->GetStyle(); } -wxFontWeight wxFont::GetWeight() const +int wxFont::GetNumericWeight() const { wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font") ); - return M_FONTDATA->GetWeight(); + return M_FONTDATA->GetNumericWeight(); } bool wxFont::GetUnderlined() const @@ -147,10 +153,10 @@ const wxNativeFontInfo *wxFont::GetNativeFontInfo() const // change font attributes // ---------------------------------------------------------------------------- -void wxFont::SetPointSize(int pointSize) +void wxFont::SetFractionalPointSize(float pointSize) { AllocExclusive(); - M_FONTDATA->SetPointSize(pointSize); + M_FONTDATA->SetFractionalPointSize(pointSize); } void wxFont::SetFamily(wxFontFamily family) @@ -165,10 +171,10 @@ void wxFont::SetStyle(wxFontStyle style) M_FONTDATA->SetStyle(style); } -void wxFont::SetWeight(wxFontWeight weight) +void wxFont::SetNumericWeight(int weight) { AllocExclusive(); - M_FONTDATA->SetWeight(weight); + M_FONTDATA->SetNumericWeight(weight); } bool wxFont::SetFaceName(const wxString& faceName)