From d7d42ad95a83feaef745a5ab8abbbdcf7d892e32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 5 Nov 2026 22:03:28 +0100 Subject: [PATCH] UI: Keep squeezed text from wrapping due to float rounding The squeeze scale is availWidth / width, and multiplying the width back by it could land a hair above availWidth (189.00002 for "PPSSPP Forums" on the credits screen), so the text got wrapped despite being scaled to fit. Shave off 0.1%. Co-Authored-By: Claude Opus 5.5 --- Common/UI/Context.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Common/UI/Context.cpp b/Common/UI/Context.cpp index 118d1ac1bc..a9c2169780 100644 --- a/Common/UI/Context.cpp +++ b/Common/UI/Context.cpp @@ -354,7 +354,9 @@ float UIContext::CalculateTextScale(std::string_view str, float availWidth) cons MeasureTextRect(theme->uiFont, 1.0f, 1.0f, str, availWidth, &actualWidth, &actualHeight, ALIGN_VCENTER); if (actualWidth > availWidth) { // TODO: Return feedback that wrapping was needed. - return std::max(MIN_TEXT_SCALE, availWidth / actualWidth); + // Shave off a little, since float rounding can otherwise leave the scaled text a hair + // wider than availWidth, and then it gets wrapped anyway. + return std::max(MIN_TEXT_SCALE, availWidth / actualWidth * 0.999f); } return 1.0f; }