aboutsummaryrefslogtreecommitdiff
path: root/engines/draci/font.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/draci/font.cpp')
-rw-r--r--engines/draci/font.cpp20
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;
}
}