MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetBroadestDigit

Function GetBroadestDigit

src/gfx.cpp:1302–1316  ·  view source on GitHub ↗

* Determine the broadest digits for guessing the maximum width of a n-digit number. * @param size Font of the digit * @returns Broadest digits, first which is not 0 (use this digit as first digit for numbers with more than one * digit.), second including 0 (use this digit for all digits, except the first one; or for numbers with * only one digit.) */

Source from the content-addressed store, hash-verified

1300 * only one digit.)
1301 */
1302std::pair<uint8_t, uint8_t> GetBroadestDigit(FontSize size)
1303{
1304 uint8_t front = 0;
1305 uint8_t next = 0;
1306 int width = -1;
1307 for (char c = '9'; c >= '0'; c--) {
1308 int w = GetCharacterWidth(size, c);
1309 if (w <= width) continue;
1310
1311 width = w;
1312 next = c - '0';
1313 if (c != '0') front = c - '0';
1314 }
1315 return {front, next};
1316}
1317
1318void ScreenSizeChanged()
1319{

Callers 1

GetParamMaxDigitsFunction · 0.85

Calls 1

GetCharacterWidthFunction · 0.85

Tested by

no test coverage detected