aboutsummaryrefslogtreecommitdiff
path: root/engines/teenagent
diff options
context:
space:
mode:
authorVladimir Menshakov2009-12-08 22:02:24 +0000
committerVladimir Menshakov2009-12-08 22:02:24 +0000
commit88c99bc73386946799626ce9d21bdebce0caf176 (patch)
tree9e76e35c547b43f6047d0edc37b2f60e24860b3a /engines/teenagent
parent84b910f7559aac2af505a9ff8761fa9e31cb9bf7 (diff)
downloadscummvm-rg350-88c99bc73386946799626ce9d21bdebce0caf176.tar.gz
scummvm-rg350-88c99bc73386946799626ce9d21bdebce0caf176.tar.bz2
scummvm-rg350-88c99bc73386946799626ce9d21bdebce0caf176.zip
allow font to be rendered out of screen
svn-id: r46295
Diffstat (limited to 'engines/teenagent')
-rw-r--r--engines/teenagent/font.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/engines/teenagent/font.cpp b/engines/teenagent/font.cpp
index 68c6c3f0c2..51de84b50e 100644
--- a/engines/teenagent/font.cpp
+++ b/engines/teenagent/font.cpp
@@ -52,15 +52,26 @@ uint Font::render(Graphics::Surface *surface, int x, int y, char c, byte color)
idx -= 0x20;
byte *glyph = data + READ_LE_UINT16(data + idx * 2);
- uint h = glyph[0], w = glyph[1];
- if (surface == NULL || surface->pixels == NULL)
+ int h = glyph[0], w = glyph[1];
+ if (surface == NULL || surface->pixels == NULL || y + h <= 0 || y >= 200 || x + w <= 0 || x >= 320)
return w - width_pack;
-
+
+ int i0 = 0, j0 = 0;
+ if (x < 0) {
+ j0 = -x;
+ x = 0;
+ }
+ if (y < 0) {
+ i0 = -y;
+ y = 0;
+ }
//debug(0, "char %c, width: %dx%d", c, w, h);
glyph += 2;
+ glyph += i0 * w + j0;
byte *dst = (byte *)surface->getBasePtr(x, y);
- for (uint i = 0; i < h; ++i) {
- for (uint j = 0; j < w; ++j) {
+ byte *end = (byte *)surface->getBasePtr(0, surface->h);
+ for (int i = i0; i < h && dst < end; ++i) {
+ for (int j = j0; j < w; ++j) {
byte v = *glyph++;
switch (v) {
case 0:
@@ -97,11 +108,14 @@ uint Font::render(Graphics::Surface *surface, int x, int y, const Common::String
Common::String line(str.c_str() + i, j - i);
//debug(0, "line: %s", line.c_str());
- uint w = render(NULL, 0, 0, line, false);
- int xp = x + (max_w - w) / 2;
- for (uint k = 0; k < line.size(); ++k) {
- xp += render(surface, xp, y, line[k], color);
- }
+ if (y + (int)height >= 0) {
+ uint w = render(NULL, 0, 0, line, false);
+ int xp = x + (max_w - w) / 2;
+ for (uint k = 0; k < line.size(); ++k) {
+ xp += render(surface, xp, y, line[k], color);
+ }
+ } else if (y >= 200)
+ break;
y += height;
i = j + 1;