Factor out function to get value with broadest digits
This commit is contained in:
18
src/gfx.cpp
18
src/gfx.cpp
@@ -1528,6 +1528,24 @@ byte GetDigitWidth(FontSize size)
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return some number that is suitable for string size computations.
|
||||
* @param count Number of digits which shall be displayable.
|
||||
* @param size Font of the number
|
||||
* @return The number.
|
||||
*/
|
||||
uint64 GetBroadestDigitsValue(uint count, FontSize size)
|
||||
{
|
||||
uint front = 0;
|
||||
uint next = 0;
|
||||
GetBroadestDigit(&front, &next, size);
|
||||
uint64 val = count > 1 ? front : next;
|
||||
for (; count > 1; count--) {
|
||||
val = 10 * val + next;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.)
|
||||
|
Reference in New Issue
Block a user