summaryrefslogtreecommitdiff
path: root/src/strings.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2013-06-01 14:33:48 +0000
committerfrosch <frosch@openttd.org>2013-06-01 14:33:48 +0000
commitce110eed32eef08e7ce1c35a2c5893698afee73a (patch)
tree0faa8ca975a1bf93428e6ac711692b7e79e7ec27 /src/strings.cpp
parentf292a87dc499fdcf9ffaeaa6f1cd73fc998b31e3 (diff)
downloadopenttd-ce110eed32eef08e7ce1c35a2c5893698afee73a.tar.xz
(svn r25313) -Fix: Do not assume '8' to be the broadest digit, but test all of them.
Diffstat (limited to 'src/strings.cpp')
-rw-r--r--src/strings.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/strings.cpp b/src/strings.cpp
index 054ebb5ca..777d5ccf4 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -96,25 +96,27 @@ void StringParameters::ShiftParameters(uint amount)
* @param max_value The biggest value which shall be displayed.
* For the result only the number of digits of \a max_value matter.
* @param min_count Minimum number of digits independent of \a max.
+ * @param size Font of the number
*/
-void SetDParamMaxValue(uint n, uint64 max_value, uint min_count)
+void SetDParamMaxValue(uint n, uint64 max_value, uint min_count, FontSize size)
{
uint num_digits = 1;
while (max_value >= 10) {
num_digits++;
max_value /= 10;
}
- SetDParamMaxDigits(n, max(min_count, num_digits));
+ SetDParamMaxDigits(n, max(min_count, num_digits), size);
}
/**
* Set DParam n to some number that is suitable for string size computations.
* @param n Index of the string parameter.
* @param count Number of digits which shall be displayable.
+ * @param size Font of the number
*/
-void SetDParamMaxDigits(uint n, uint count)
+void SetDParamMaxDigits(uint n, uint count, FontSize size)
{
- static const uint biggest_digit = 8; ///< Digit with the biggest string width.
+ uint biggest_digit = GetBroadestDigit(size);
uint64 val = biggest_digit;
for (; count > 1; count--) {
val = 10 * val + biggest_digit;