From ce110eed32eef08e7ce1c35a2c5893698afee73a Mon Sep 17 00:00:00 2001 From: frosch Date: Sat, 1 Jun 2013 14:33:48 +0000 Subject: (svn r25313) -Fix: Do not assume '8' to be the broadest digit, but test all of them. --- src/gfx.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/gfx.cpp') 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() { -- cgit v1.2.3-70-g09d2