From c55d1e7799f112ef9f0c75ee60fc2ede28745990 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 2 May 2016 10:56:49 -0400 Subject: [PATCH] Fit both height and width when choosing the font size --- src/widgets/Ruler.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/widgets/Ruler.cpp b/src/widgets/Ruler.cpp index 773ac7912..8151ffa94 100644 --- a/src/widgets/Ruler.cpp +++ b/src/widgets/Ruler.cpp @@ -1914,12 +1914,15 @@ wxFont &AdornedRulerPanel::GetButtonFont() const mButtonFont.SetPointSize(mButtonFontSize); wxCoord width, height; for (auto button = StatusChoice::FirstButton; done && IsButton(button); ++button) { - auto allowableWidth = GetButtonRect(button).GetWidth() - 2; - // 2 corresponds with the Inflate(-1, -1) + auto rect = GetButtonRect(button); + auto availableWidth = rect.GetWidth() - 2; // Corresponds to Inflate(-1, -1) + auto availableHeight = rect.GetHeight() - 2; // Corresponds to Inflate(-1, -1) GetParent()->GetTextExtent( wxGetTranslation(GetPushButtonStrings(button)->label), &width, &height, NULL, NULL, &mButtonFont); - done = width < allowableWidth; + + // Yes, < not <= ! Leave at least some room. + done = width < availableWidth && height < availableHeight; } mButtonFontSize--; } while (mButtonFontSize > 0 && !done);