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 <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-11-05 22:03:38 +01:00
1 parent 1bce9352fb
commit d7d42ad95a
1 file changed
+3 -1
+3 -1
View File
@@ -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;
}