# HG changeset patch # User Darkvater # Date 1157497351 0 # Node ID 112872feb6fda5c698b6aba1e168f56054136584 # Parent 693f37c36c85713ca7c9d52c92426b567ef777e7 (svn r6404) -Fix: GetStringWidth failed to calculate correct string width if the string contained newlines. diff -r 693f37c36c85 -r 112872feb6fd gfx.c --- a/gfx.c Tue Sep 05 16:40:23 2006 +0000 +++ b/gfx.c Tue Sep 05 23:02:31 2006 +0000 @@ -542,8 +542,10 @@ int GetStringWidth(const char *str) { FontSize size = _cur_fontsize; - int w = 0; + int w, max_w; byte c; + + w = max_w = 0; for (c = *str; c != '\0'; c = *(++str)) { if (c >= ASCII_LETTERSTART) { w += GetCharacterWidth(size, c); @@ -552,9 +554,11 @@ else if (c == ASCII_SETXY) str += 2; else if (c == ASCII_TINYFONT) size = FS_SMALL; else if (c == ASCII_BIGFONT) size = FS_LARGE; + else if (c == ASCII_NL && w > max_w) {max_w = w; w = 0;} } } - return w; + + return max(w, max_w); }