diff options
author | Paul Gilbert | 2015-02-07 18:43:05 -0500 |
---|---|---|
committer | Paul Gilbert | 2015-02-07 18:43:05 -0500 |
commit | 996ce240833477855f5787a9f3501e8dc8ba8022 (patch) | |
tree | 18bfed9a6c5df8c28bd4107432e30f7896cf91b9 /engines/xeen/font.cpp | |
parent | c313113f6b72524c1bdc41fd30c2bdc4182de3a4 (diff) | |
download | scummvm-rg350-996ce240833477855f5787a9f3501e8dc8ba8022.tar.gz scummvm-rg350-996ce240833477855f5787a9f3501e8dc8ba8022.tar.bz2 scummvm-rg350-996ce240833477855f5787a9f3501e8dc8ba8022.zip |
XEEN: Fix writeString to constrain text to window
Diffstat (limited to 'engines/xeen/font.cpp')
-rw-r--r-- | engines/xeen/font.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/engines/xeen/font.cpp b/engines/xeen/font.cpp index aca747e776..53308ae248 100644 --- a/engines/xeen/font.cpp +++ b/engines/xeen/font.cpp @@ -60,7 +60,7 @@ void FontSurface::writeSymbol(int symbolId) { /** * Write a string to the surface * @param s String to display - * @param bounds Window bounds to display string within + * @param clipRect Window bounds to display string within * @returns Any string remainder that couldn't be displayed * @remarks Note that bounds is just used for wrapping purposes. Unless * justification is set, the message will be written at _writePos @@ -183,7 +183,7 @@ Common::String FontSurface::writeString(const Common::String &s, const Common::R continue; } else if (c == 6) { // Non-breakable space - writeChar(' '); + writeChar(' ', bounds); } else if (c == 7) { // Set text background color int bgColor = fontAtoi(); @@ -210,7 +210,7 @@ Common::String FontSurface::writeString(const Common::String &s, const Common::R Common::copy(&_textColors[0], &_textColors[4], &oldColor[0]); _textColors[1] = _textColors[2] = _textColors[3] = _bgColor; - writeChar(c); + writeChar(c, bounds); Common::copy(&oldColor[0], &oldColor[4], &_textColors[0]); _writePos.x = oldX; @@ -239,7 +239,7 @@ Common::String FontSurface::writeString(const Common::String &s, const Common::R break; } else { // Standard character - write it out - writeChar(c); + writeChar(c, bounds); } } @@ -340,7 +340,7 @@ void FontSurface::setTextColor(int idx) { /** * Wrie a character to the surface */ -void FontSurface::writeChar(char c) { +void FontSurface::writeChar(char c, const Common::Rect &clipRect) { // Get y position, handling kerning int y = _writePos.y; if (c == 'g' || c == 'p' || c == 'q' || c == 'y') @@ -354,11 +354,17 @@ void FontSurface::writeChar(char c) { uint16 lineData = READ_LE_UINT16(srcP); srcP += 2; byte *destP = (byte *)getBasePtr(_writePos.x, y); + // Ignore line if it's outside the clipping rect + if (y < clipRect.top || y >= clipRect.bottom) + continue; + const byte *lineStart = (const byte *)getBasePtr(clipRect.left, y); + const byte *lineEnd = (const byte *)getBasePtr(clipRect.right, y); + for (int xp = 0; xp < FONT_WIDTH; ++xp, ++destP) { int colIndex = lineData & 3; lineData >>= 2; - if (colIndex) + if (colIndex && destP >= lineStart && destP < lineEnd) *destP = _textColors[colIndex]; } } |