SCUMM/FM-TOWNS: start fixing japanese font drawing
svn-id: r53196
This commit is contained in:
parent
2d8e94e4ff
commit
2f86c7a45c
2 changed files with 59 additions and 23 deletions
|
@ -456,21 +456,51 @@ void CharsetRendererV3::setCurID(int32 id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int CharsetRendererCommon::getFontHeight() {
|
int CharsetRendererCommon::getFontHeight() {
|
||||||
if (_vm->_useCJKMode)
|
if (_vm->_useCJKMode) {
|
||||||
return MAX(_vm->_2byteHeight + 1, _fontHeight);
|
if (_vm->_game.platform == Common::kPlatformFMTowns) {
|
||||||
else
|
static const uint8 sjisFontHeightM1[] = { 0, 9, 10, 9, 10, 9, 10, 0, 0 };
|
||||||
|
static const uint8 sjisFontHeightM2[] = { 8, 8, 9, 9, 9, 8, 9, 9, 9, 8 };
|
||||||
|
static const uint8 sjisFontHeightI4[] = { 8, 8, 9, 9, 9, 8, 8, 8, 8, 8 };
|
||||||
|
const uint8 *htbl = (_vm->_game.id == GID_MONKEY) ? sjisFontHeightM1 : ((_vm->_game.id == GID_INDY4) ? sjisFontHeightI4 : sjisFontHeightM2);
|
||||||
|
return htbl[_curId];
|
||||||
|
} else {
|
||||||
|
return MAX(_vm->_2byteHeight + 1, _fontHeight);
|
||||||
|
}
|
||||||
|
} else
|
||||||
return _fontHeight;
|
return _fontHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do spacing for variable width old-style font
|
// do spacing for variable width old-style font
|
||||||
int CharsetRendererClassic::getCharWidth(byte chr) {
|
int CharsetRendererClassic::getCharWidth(uint16 chr) {
|
||||||
if (chr >= 0x80 && _vm->_useCJKMode)
|
|
||||||
return _vm->_2byteWidth / 2;
|
|
||||||
int spacing = 0;
|
int spacing = 0;
|
||||||
|
|
||||||
int offs = READ_LE_UINT32(_fontPtr + chr * 4 + 4);
|
if (_vm->_game.platform == Common::kPlatformFMTowns) {
|
||||||
if (offs) {
|
if (_vm->_useCJKMode) {
|
||||||
spacing = _fontPtr[offs] + (signed char)_fontPtr[offs + 2];
|
if ((chr & 0xff00) == 0xfd00) {
|
||||||
|
chr &= 0xff;
|
||||||
|
} else if (chr >= 256) {
|
||||||
|
spacing = 9;
|
||||||
|
} else if (chr >= 128) {
|
||||||
|
spacing = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (spacing) {
|
||||||
|
static const uint8 sjisWidthM1[] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||||
|
static const uint8 sjisWidthM2[] = { 0, 1, 1, 1, 1, 0, 1, 1, 1, 0 };
|
||||||
|
static const uint8 sjisWidthI4[] = { 0, 0, 1, 1, 1, 0, 0, 0, 0, 0 };
|
||||||
|
const uint8 *wtbl = (_vm->_game.id == GID_MONKEY) ? sjisWidthM1 : ((_vm->_game.id == GID_INDY4) ? sjisWidthI4 : sjisWidthM2);
|
||||||
|
spacing += wtbl[_curId];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (chr >= 0x80 && _vm->_useCJKMode) {
|
||||||
|
return _vm->_2byteWidth / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!spacing) {
|
||||||
|
int offs = READ_LE_UINT32(_fontPtr + chr * 4 + 4);
|
||||||
|
if (offs) {
|
||||||
|
spacing = _fontPtr[offs] + (signed char)_fontPtr[offs + 2];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return spacing;
|
return spacing;
|
||||||
|
@ -479,7 +509,7 @@ int CharsetRendererClassic::getCharWidth(byte chr) {
|
||||||
int CharsetRenderer::getStringWidth(int arg, const byte *text) {
|
int CharsetRenderer::getStringWidth(int arg, const byte *text) {
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
int width = 1;
|
int width = 1;
|
||||||
byte chr;
|
uint16 chr;
|
||||||
int oldID = getCurID();
|
int oldID = getCurID();
|
||||||
int code = (_vm->_game.heversion >= 80) ? 127 : 64;
|
int code = (_vm->_game.heversion >= 80) ? 127 : 64;
|
||||||
|
|
||||||
|
@ -537,12 +567,18 @@ int CharsetRenderer::getStringWidth(int arg, const byte *text) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((chr & 0x80) && _vm->_useCJKMode) {
|
|
||||||
pos++;
|
if (_vm->_useCJKMode) {
|
||||||
width += _vm->_2byteWidth;
|
if (_vm->_game.platform == Common::kPlatformFMTowns) {
|
||||||
} else {
|
if ((chr >= 0x80 && chr <= 0x9f) || (chr >= 0xe0 && chr <= 0xfd))
|
||||||
width += getCharWidth(chr);
|
chr = (chr << 8) | text[pos++];
|
||||||
|
} else if (chr & 0x80) {
|
||||||
|
pos++;
|
||||||
|
width += _vm->_2byteWidth;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
width += getCharWidth(chr);
|
||||||
}
|
}
|
||||||
|
|
||||||
setCurID(oldID);
|
setCurID(oldID);
|
||||||
|
@ -634,7 +670,7 @@ void CharsetRenderer::addLinebreaks(int a, byte *str, int pos, int maxwidth) {
|
||||||
setCurID(oldID);
|
setCurID(oldID);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CharsetRendererV3::getCharWidth(byte chr) {
|
int CharsetRendererV3::getCharWidth(uint16 chr) {
|
||||||
if (chr & 0x80 && _vm->_useCJKMode)
|
if (chr & 0x80 && _vm->_useCJKMode)
|
||||||
return _vm->_2byteWidth / 2;
|
return _vm->_2byteWidth / 2;
|
||||||
int spacing = 0;
|
int spacing = 0;
|
||||||
|
@ -1258,7 +1294,7 @@ int CharsetRendererNut::getCharHeight(byte chr) {
|
||||||
return _current->getCharHeight(chr);
|
return _current->getCharHeight(chr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CharsetRendererNut::getCharWidth(byte chr) {
|
int CharsetRendererNut::getCharWidth(uint16 chr) {
|
||||||
assert(_current);
|
assert(_current);
|
||||||
return _current->getCharWidth(chr);
|
return _current->getCharWidth(chr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ public:
|
||||||
|
|
||||||
virtual int getFontHeight() = 0;
|
virtual int getFontHeight() = 0;
|
||||||
virtual int getCharHeight(byte chr) { return getFontHeight(); }
|
virtual int getCharHeight(byte chr) { return getFontHeight(); }
|
||||||
virtual int getCharWidth(byte chr) = 0;
|
virtual int getCharWidth(uint16 chr) = 0;
|
||||||
|
|
||||||
virtual void setColor(byte color) { _color = color; translateColor(); }
|
virtual void setColor(byte color) { _color = color; translateColor(); }
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ public:
|
||||||
void printChar(int chr, bool ignoreCharsetMask);
|
void printChar(int chr, bool ignoreCharsetMask);
|
||||||
void drawChar(int chr, const Graphics::Surface &s, int x, int y);
|
void drawChar(int chr, const Graphics::Surface &s, int x, int y);
|
||||||
|
|
||||||
int getCharWidth(byte chr);
|
int getCharWidth(uint16 chr);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CharsetRendererNES : public CharsetRendererCommon {
|
class CharsetRendererNES : public CharsetRendererCommon {
|
||||||
|
@ -151,7 +151,7 @@ public:
|
||||||
void drawChar(int chr, const Graphics::Surface &s, int x, int y);
|
void drawChar(int chr, const Graphics::Surface &s, int x, int y);
|
||||||
|
|
||||||
int getFontHeight() { return 8; }
|
int getFontHeight() { return 8; }
|
||||||
int getCharWidth(byte chr) { return 8; }
|
int getCharWidth(uint16 chr) { return 8; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class CharsetRendererV3 : public CharsetRendererCommon {
|
class CharsetRendererV3 : public CharsetRendererCommon {
|
||||||
|
@ -165,7 +165,7 @@ public:
|
||||||
void drawChar(int chr, const Graphics::Surface &s, int x, int y);
|
void drawChar(int chr, const Graphics::Surface &s, int x, int y);
|
||||||
void setCurID(int32 id);
|
void setCurID(int32 id);
|
||||||
void setColor(byte color);
|
void setColor(byte color);
|
||||||
int getCharWidth(byte chr);
|
int getCharWidth(uint16 chr);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USE_RGB_COLOR
|
#ifdef USE_RGB_COLOR
|
||||||
|
@ -189,7 +189,7 @@ public:
|
||||||
~CharsetRendererV2();
|
~CharsetRendererV2();
|
||||||
|
|
||||||
void setCurID(int32 id) {}
|
void setCurID(int32 id) {}
|
||||||
int getCharWidth(byte chr) { return 8; }
|
int getCharWidth(uint16 chr) { return 8; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef ENABLE_SCUMM_7_8
|
#ifdef ENABLE_SCUMM_7_8
|
||||||
|
@ -208,7 +208,7 @@ public:
|
||||||
|
|
||||||
int getFontHeight();
|
int getFontHeight();
|
||||||
int getCharHeight(byte chr);
|
int getCharHeight(byte chr);
|
||||||
int getCharWidth(byte chr);
|
int getCharWidth(uint16 chr);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue