From 24c83625f6bf10d03cc1d474320b57be508b2cf6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 12 Sep 2018 19:42:55 +0200 Subject: [PATCH] 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. --- include/wx/osx/font.h | 19 ----------------- src/osx/carbon/font.cpp | 46 +++++++++++++++++------------------------ 2 files changed, 19 insertions(+), 46 deletions(-) diff --git a/include/wx/osx/font.h b/include/wx/osx/font.h index 50ebb978d0..3d6591cda3 100644 --- a/include/wx/osx/font.h +++ b/include/wx/osx/font.h @@ -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); diff --git a/src/osx/carbon/font.cpp b/src/osx/carbon/font.cpp index d15b5fd189..106ab44902 100644 --- a/src/osx/carbon/font.cpp +++ b/src/osx/carbon/font.cpp @@ -542,13 +542,17 @@ wxFont::wxFont(const wxString& fontdesc) wxFont::wxFont(const wxFontInfo& info) { - Create(info.GetFractionalPointSize(), - info.GetFamily(), - info.GetStyle(), - info.GetNumericWeight(), - info.IsUnderlined(), - info.GetFaceName(), - info.GetEncoding()); + m_refData = new wxFontRefData + ( + info.GetFractionalPointSize(), + info.GetFamily(), + info.GetStyle(), + info.GetNumericWeight(), + info.IsUnderlined(), + info.IsStrikethrough(), + info.GetFaceName(), + 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), - family, style, - GetNumericWeightOf(weight), - underlined, faceName, encoding); + m_refData = new wxFontRefData + ( + wxFontInfo::ToFloatPointSize(pointSize), + family, style, + GetNumericWeightOf(weight), + underlined, false, faceName, encoding + ); + return true; } wxFont::~wxFont()