diff options
author | Denis Kasak | 2009-07-29 16:39:12 +0000 |
---|---|---|
committer | Denis Kasak | 2009-07-29 16:39:12 +0000 |
commit | bc89ce23d38c2d26ae5336297d628099cdbf8498 (patch) | |
tree | bf2ffa5dfaec16d89152ab70b1ce57851de8c6e0 /engines/draci | |
parent | e9669b8e2bcc4a65d5cc1225e9328d9171726690 (diff) | |
download | scummvm-rg350-bc89ce23d38c2d26ae5336297d628099cdbf8498.tar.gz scummvm-rg350-bc89ce23d38c2d26ae5336297d628099cdbf8498.tar.bz2 scummvm-rg350-bc89ce23d38c2d26ae5336297d628099cdbf8498.zip |
Fixed text bugs related to the fact that some strings in the data files don't end with '|' like they should.
svn-id: r42897
Diffstat (limited to 'engines/draci')
-rw-r--r-- | engines/draci/font.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/engines/draci/font.cpp b/engines/draci/font.cpp index 2a6e5989f0..b867bf4877 100644 --- a/engines/draci/font.cpp +++ b/engines/draci/font.cpp @@ -266,17 +266,21 @@ int Font::getStringWidth(const Common::String &str, int spacing) const { for (unsigned int i = 0, tmp = 0; i < len; ++i) { - // Newline char encountered, skip it and store the new length if it is greater - if (str[i] == '|') { + if (str[i] != '|') { + uint8 charIndex = str[i] - kCharIndexOffset; + tmp += _charWidths[charIndex]; + tmp += spacing; + } + + // Newline char encountered, skip it and store the new length if it is greater. + // Also, all strings in the data files should end with '|' but not all do. + // This is why we check whether we are at the last char too. + if (str[i] == '|' || i == len - 1) { if (tmp > width) { width = tmp; } continue; } - - uint8 charIndex = str[i] - kCharIndexOffset; - tmp += _charWidths[charIndex]; - tmp += spacing; } return width + 1; @@ -298,7 +302,9 @@ int Font::getStringHeight(const Common::String &str) const { int separators = 0; for (unsigned int i = 0; i < len; ++i) { - if (str[i] == '|') { + // All strings in the data files should end with '|' but not all do. + // This is why we check whether we are at the last char too. + if (str[i] == '|' || i == len - 1) { ++separators; } } |