mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-13 09:39:33 +01:00
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:
1 parent
1bce9352fb
commit
d7d42ad95a
1 file changed
+3
-1
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user