From 0d8d66cb82c4b6236af4b05e36f5a69461597580 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 24 Jan 2015 18:31:54 -0500 Subject: XEEN: Fix center aligning text in writeString --- engines/xeen/font.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/engines/xeen/font.cpp b/engines/xeen/font.cpp index aee05f9066..1668ef5ae8 100644 --- a/engines/xeen/font.cpp +++ b/engines/xeen/font.cpp @@ -113,8 +113,10 @@ Common::String FontSurface::writeString(const Common::String &s, const Common::R } } else { // Found word break, find end of previous word - while (displayEnd > _displayString && (*displayEnd & 0x7f) == ' ') - --displayEnd; + while (endP > _displayString && (*endP & 0x7f) == ' ') + --endP; + + displayEnd = endP; } } @@ -123,9 +125,12 @@ Common::String FontSurface::writeString(const Common::String &s, const Common::R // Figure out the width of the selected portion of the string int totalWidth = 0; while (!getNextCharWidth(totalWidth)) { - if (_displayString > displayEnd && *displayEnd == ' ') { - // Don't include any ending space as part of the total - totalWidth -= _fontReduced ? 4 : 5; + if (_displayString > displayEnd) { + if (*displayEnd == ' ') { + // Don't include any ending space as part of the total + totalWidth -= _fontReduced ? 4 : 5; + } + break; } } -- cgit v1.2.3