diff options
author | frosch <frosch@openttd.org> | 2012-03-17 16:42:34 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2012-03-17 16:42:34 +0000 |
commit | 49fdf6dd26a1584500629b37345a5308407d3fce (patch) | |
tree | 69d22a79169d730e9b3b6739bd75e0d838a81e61 /src | |
parent | 161b6c348b5db6b4177ab5d2eb47607e1b706035 (diff) | |
download | openttd-49fdf6dd26a1584500629b37345a5308407d3fce.tar.xz |
(svn r24038) -Fix (r23472): After opening a textwindow with the monospaced font, all other text started glitching.
Diffstat (limited to 'src')
-rw-r--r-- | src/gfx.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp index 5a5c45972..63baa999d 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -45,6 +45,7 @@ SwitchMode _switch_mode; ///< The next mainloop command. PauseModeByte _pause_mode; Palette _cur_palette; +static Dimension _max_char_size[FS_END]; ///< Cache of the maximum size of any character of a font. static int _max_char_height; ///< Cache of the height of the largest font static int _max_char_width; ///< Cache of the width of the largest font static byte _stringwidth_table[FS_END][224]; ///< Cache containing width of often used characters. @see GetCharacterWidth() @@ -1551,20 +1552,25 @@ void DoPaletteAnimations() */ void LoadStringWidthTable(bool monospace) { - _max_char_height = 0; - _max_char_width = 0; - for (FontSize fs = monospace ? FS_MONO : FS_BEGIN; fs < (monospace ? FS_END : FS_MONO); fs++) { - _max_char_height = max<int>(_max_char_height, GetCharacterHeight(fs)); + _max_char_size[fs].width = 0; + _max_char_size[fs].height = GetCharacterHeight(fs); for (uint i = 0; i != 224; i++) { _stringwidth_table[fs][i] = GetGlyphWidth(fs, i + 32); - _max_char_width = max<int>(_max_char_width, _stringwidth_table[fs][i]); + _max_char_size[fs].width = max<int>(_max_char_size[fs].width, _stringwidth_table[fs][i]); } + + /* Needed because they need to be 1 more than the widest. */ + _max_char_size[fs].width++; + _max_char_size[fs].height++; } - /* Needed because they need to be 1 more than the widest. */ - _max_char_height++; - _max_char_width++; + _max_char_width = 0; + _max_char_height = 0; + for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) { + _max_char_width = max<int>(_max_char_width, _max_char_size[fs].width); + _max_char_height = max<int>(_max_char_height, _max_char_size[fs].height); + } ReInitAllWindows(); } |