From 3e728170b2ba6dcbe0d941aa0d4e72330c587d81 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 2 Jul 2019 11:43:06 +0200 Subject: [PATCH] Fix best size of wxMSW wxSpinCtrl with non-default font This has been broken by dce65bed1ca463b75c0ec948f6f54b258f663e37 after which the actual font used for the control was not taken into account any longer. Fix this by ensuring the wxTextCtrl used for size calculation uses the same font as wxSpinCtrl itself. See #12297, #18391. Closes #18427. --- src/msw/spinctrl.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/msw/spinctrl.cpp b/src/msw/spinctrl.cpp index 1835296b47..222c787bc9 100644 --- a/src/msw/spinctrl.cpp +++ b/src/msw/spinctrl.cpp @@ -739,6 +739,11 @@ wxSize wxSpinCtrl::DoGetSizeFromTextSize(int xlen, int ylen) const wxTextCtrl text; TempHWNDSetter set(&text, m_hwndBuddy); + // It's unnecessary to actually change the font used by the buddy control, + // but we do need to ensure that the helper wxTextCtrl wxFont matches what + // it is used as GetSizeFromTextSize() uses the current font. + text.wxWindowBase::SetFont(GetFont()); + // Increase the width to accommodate the button, which should fit inside // the text control while taking account of the overlap. return text.GetSizeFromTextSize(xlen + sizeBtn.x - GetOverlap(), ylen);