aboutsummaryrefslogtreecommitdiff
path: root/engines/toon/font.cpp
diff options
context:
space:
mode:
authoreriktorbjorn2011-06-26 23:13:49 +0200
committereriktorbjorn2011-06-26 23:13:49 +0200
commite8c704a02573fca7ebe99cbaa9b27eb4382d40f6 (patch)
tree23dddd18fe5b223da8ec737506ad3ac7e2e4de1b /engines/toon/font.cpp
parentbce549f42a374e47c5de794c863d6cbe0842bfb4 (diff)
downloadscummvm-rg350-e8c704a02573fca7ebe99cbaa9b27eb4382d40f6.tar.gz
scummvm-rg350-e8c704a02573fca7ebe99cbaa9b27eb4382d40f6.tar.bz2
scummvm-rg350-e8c704a02573fca7ebe99cbaa9b27eb4382d40f6.zip
TOON: Fix the bottom pixels of text being cut off
It's a dirty rect problem. The computeSize() function needs to take into consideration that the glyph may be offset, so it's not enough to just look at its size. For now, I'm assuming that this is only a problem with characters that stick out below the base line, so that's all this patch tries to fix. Let's see if that's enough.
Diffstat (limited to 'engines/toon/font.cpp')
-rw-r--r--engines/toon/font.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/engines/toon/font.cpp b/engines/toon/font.cpp
index 4c491ae2b3..63304c905f 100644
--- a/engines/toon/font.cpp
+++ b/engines/toon/font.cpp
@@ -21,6 +21,7 @@
*/
#include "common/debug.h"
+#include "common/rect.h"
#include "toon/font.h"
@@ -80,7 +81,7 @@ void FontRenderer::renderText(int32 x, int32 y, Common::String origText, int32 m
x -= xx / 2;
}
- _vm->addDirtyRect(x, y, x + xx + 2, y + yy);
+ _vm->addDirtyRect(x, y, x + xx, y + yy);
int32 curX = x;
int32 curY = y;
@@ -110,6 +111,7 @@ void FontRenderer::computeSize(Common::String origText, int32 *retX, int32 *retY
int32 lineHeight = 0;
int32 totalHeight = 0;
int32 totalWidth = 0;
+ int32 lastLineHeight = 0;
const byte *text = (const byte *)origText.c_str();
while (*text) {
@@ -122,17 +124,25 @@ void FontRenderer::computeSize(Common::String origText, int32 *retX, int32 *retY
totalHeight += lineHeight;
lineHeight = 0;
lineWidth = 0;
+ lastLineHeight = 0;
} else {
curChar = textToFont(curChar);
int32 charWidth = _currentFont->getFrameWidth(curChar) - 1;
int32 charHeight = _currentFont->getFrameHeight(curChar);
lineWidth += charWidth;
lineHeight = MAX(lineHeight, charHeight);
+
+ // The character may be offset, so the height doesn't
+ // really tell how far it will stick out. For now,
+ // assume we only need to take the lower bound into
+ // consideration.
+ Common::Rect charRect = _currentFont->getFrameRect(curChar);
+ lastLineHeight = MAX<int32>(lastLineHeight, charRect.bottom);
}
text++;
}
- totalHeight += lineHeight;
+ totalHeight += lastLineHeight;
totalWidth = MAX(totalWidth, lineWidth);
*retX = totalWidth;