diff options
author | frosch <frosch@openttd.org> | 2013-06-01 14:33:48 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2013-06-01 14:33:48 +0000 |
commit | ce110eed32eef08e7ce1c35a2c5893698afee73a (patch) | |
tree | 0faa8ca975a1bf93428e6ac711692b7e79e7ec27 /src/gfx.cpp | |
parent | f292a87dc499fdcf9ffaeaa6f1cd73fc998b31e3 (diff) | |
download | openttd-ce110eed32eef08e7ce1c35a2c5893698afee73a.tar.xz |
(svn r25313) -Fix: Do not assume '8' to be the broadest digit, but test all of them.
Diffstat (limited to 'src/gfx.cpp')
-rw-r--r-- | src/gfx.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp index a3112651a..b9249af47 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -1689,6 +1689,24 @@ byte GetDigitWidth(FontSize size) return width; } +/** + * Return the digit with the biggest width. + * @param size Font of the digit + * @return Broadest digit. + */ +uint GetBroadestDigit(FontSize size) +{ + uint digit = 0; + byte width = 0; + for (char c = '0'; c <= '9'; c++) { + byte w = GetCharacterWidth(size, c); + if (w > width) { + width = w; + digit = c - '0'; + } + } + return digit; +} void ScreenSizeChanged() { |