mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-20 10:52:41 +01:00
(svn r25340) [1.3] -Backport from trunk:
- Fix: Loading only 8 bits into a 16 bit variable could cause endianness problems (r25337) - Fix: Check for zero width space in translations and fail upon finding them [FS#5589] (r25326) - Fix: [SDL] Keyboard input stopped working after fullscreen toggle [FS#5580] (r25318) - Fix: Proper size-estimation for numbers with n digits, i.e. not assume a particular number is the widest [FS#5562] (r25314, r25313)
This commit is contained in:
18
src/gfx.cpp
18
src/gfx.cpp
@@ -1621,6 +1621,24 @@ byte GetDigitWidth(FontSize size)
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the broadest digits for guessing the maximum width of a n-digit number.
|
||||
* @param [out] front Broadest digit, which is not 0. (Use this digit as first digit for numbers with more than one digit.)
|
||||
* @param [out] next Broadest digit, including 0. (Use this digit for all digits, except the first one; or for numbers with only one digit.)
|
||||
* @param size Font of the digit
|
||||
*/
|
||||
void GetBroadestDigit(uint *front, uint *next, FontSize size)
|
||||
{
|
||||
int width = -1;
|
||||
for (char c = '9'; c >= '0'; c--) {
|
||||
int w = GetCharacterWidth(size, c);
|
||||
if (w > width) {
|
||||
width = w;
|
||||
*next = c - '0';
|
||||
if (c != '0') *front = c - '0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenSizeChanged()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user