SCUMM: (COMI/CJK) - fix font glitch

It seems to affect only the GUI (but that may be random). We need to extend the string rect by 1 pixel for the left side shadow of the first character.
This commit is contained in:
athrxx 2022-08-07 22:33:05 +02:00
parent 3b3be12dcb
commit fc3845a593

View file

@ -183,11 +183,15 @@ void TextRenderer_v7::drawString(const char *str, byte *buffer, Common::Rect &cl
int totalLen = (int)strlen(str); int totalLen = (int)strlen(str);
int lineStart = 0; int lineStart = 0;
int xAdj = 0;
// COMI always does this for CJK strings (before any other possible yPos fixes). // COMI always does this for CJK strings (before any other possible yPos fixes).
if (_gameId == GID_CMI) { if (_gameId == GID_CMI) {
if (_useCJKMode) if (_useCJKMode) {
y += 2; y += 2;
if (col != 0)
xAdj = 1; // x-adjust for left side glyph shadow
}
// No idea whether it is actually used. We currently don't handle this flag. // No idea whether it is actually used. We currently don't handle this flag.
/*if (flags & 0x40) /*if (flags & 0x40)
y -= (getStringHeight(str, totalLen) / 2);*/ y -= (getStringHeight(str, totalLen) / 2);*/
@ -223,8 +227,8 @@ void TextRenderer_v7::drawString(const char *str, byte *buffer, Common::Rect &cl
lineStart = pos + 1; lineStart = pos + 1;
} }
clipRect.left = (flags & kStyleAlignCenter) ? x - maxWidth / 2 : ((flags & kStyleAlignRight) ? x - maxWidth : x); clipRect.left = MAX<int>(0, ((flags & kStyleAlignCenter) ? x - maxWidth / 2 : ((flags & kStyleAlignRight) ? x - maxWidth : x)) - xAdj);
clipRect.right = MIN<int>(clipRect.right, clipRect.left + maxWidth); clipRect.right = MIN<int>(clipRect.right, clipRect.left + xAdj + maxWidth);
clipRect.top = y2; clipRect.top = y2;
clipRect.bottom = y + (_newStyle ? 0 : 1); clipRect.bottom = y + (_newStyle ? 0 : 1);
} }
@ -263,10 +267,14 @@ void TextRenderer_v7::drawStringWrap(const char *str, byte *buffer, Common::Rect
int maxWidth = 0; int maxWidth = 0;
int curWidth = 0; int curWidth = 0;
int curPos = -1; int curPos = -1;
int xAdj = 0;
// COMI does this for CJK strings (before any other possible yPos fixes, see lines 343 - 355). // COMI does this for CJK strings (before any other possible yPos fixes, see lines 343 - 355).
if (_gameId == GID_CMI && _useCJKMode) if (_gameId == GID_CMI && _useCJKMode) {
y += 2; y += 2;
if (col != 0)
xAdj = 1; // x-adjust for left side glyph shadow
}
while (curPos < len) { while (curPos < len) {
int textStart = curPos + 1; int textStart = curPos + 1;
@ -374,8 +382,8 @@ void TextRenderer_v7::drawStringWrap(const char *str, byte *buffer, Common::Rect
y += getStringHeight(str + substrStart[i], len); y += getStringHeight(str + substrStart[i], len);
} }
clipRect.left = (flags & kStyleAlignCenter) ? x - maxWidth / 2 : ((flags & kStyleAlignRight) ? x - maxWidth : x); clipRect.left = MAX<int>(0, ((flags & kStyleAlignCenter) ? x - maxWidth / 2 : ((flags & kStyleAlignRight) ? x - maxWidth : x)) - xAdj);
clipRect.right = MIN<int>(clipRect.right, clipRect.left + maxWidth); clipRect.right = MIN<int>(clipRect.right, clipRect.left + xAdj + maxWidth);
clipRect.top = y2; clipRect.top = y2;
clipRect.bottom = y + (_newStyle ? 0 : 1); clipRect.bottom = y + (_newStyle ? 0 : 1);
} }