diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/screen.cpp | 43 | ||||
-rw-r--r-- | engines/kyra/screen.h | 11 |
2 files changed, 23 insertions, 31 deletions
diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index 1e568c2236..921c7f2c17 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -102,7 +102,7 @@ bool Screen::init() { if (!font) error("Could not load any SJIS font, neither the original nor ScummVM's 'SJIS.FNT'"); - _fonts[FID_SJIS_FNT] = new SJISFont(font, _sjisInvisibleColor, _use16ColorMode); + _fonts[FID_SJIS_FNT] = new SJISFont(this, font, _sjisInvisibleColor, _use16ColorMode, !_use16ColorMode); } } @@ -1135,7 +1135,6 @@ int Screen::getFontWidth() const { int Screen::getCharWidth(uint16 c) const { if (isSJISChar(c)) - // _charWidth does not apply to sjis (rom) fonts return _fonts[FID_SJIS_FNT]->getCharWidth(c); else return _fonts[_currentFont]->getCharWidth(c) + _charWidth; @@ -1169,10 +1168,6 @@ void Screen::printText(const char *str, int x, int y, uint8 color1, uint8 color2 cmap[1] = color1; setTextColor(cmap, 0, 1); - /*FontId oldFont = FID_NUM; - if (requiresSJISFont(str)) - oldFont = setFont(FID_SJIS_FNT);*/ - const uint8 charHeightFnt = getFontHeight(); if (x < 0) @@ -1207,9 +1202,6 @@ void Screen::printText(const char *str, int x, int y, uint8 color1, uint8 color2 x += charWidth; } } - - /*if (oldFont != FID_NUM) - setFont(oldFont);*/ } bool Screen::isSJISChar(uint16 c) const { @@ -1224,18 +1216,6 @@ bool Screen::isSJISChar(uint16 c) const { return false; } -bool Screen::requiresSJISFont(const char *s) const { - if (!_useSJIS) - return false; - - while (*s) { - if (isSJISChar(fetchChar(s))) - return true; - } - - return false; -} - uint16 Screen::fetchChar(const char *&s) const { if (_currentFont != FID_SJIS_FNT) return (uint8)*s++; @@ -3341,11 +3321,15 @@ void AMIGAFont::unload() { memset(_chars, 0, sizeof(_chars)); } -SJISFont::SJISFont(Graphics::FontSJIS *font, const uint8 invisColor, bool is16Color) - : _colorMap(0), _font(font), _invisColor(invisColor), _is16Color(is16Color) { +SJISFont::SJISFont(Screen *s, Graphics::FontSJIS *font, const uint8 invisColor, bool is16Color, bool outlineSize) + : _colorMap(0), _font(font), _invisColor(invisColor), _is16Color(is16Color), _screen(s) { assert(_font); - _font->enableOutline(!is16Color); - _font->toggleCharSize(is16Color); + + _font->enableOutline(outlineSize); + + _sjisWidth = _font->getMaxFontWidth() >> 1; + _fontHeight = _font->getFontHeight() >> 1; + _asciiWidth = _font->getCharWidth('a'); } void SJISFont::unload() { @@ -3354,15 +3338,18 @@ void SJISFont::unload() { } int SJISFont::getHeight() const { - return _font->getFontHeight() >> 1; + return _fontHeight; } int SJISFont::getWidth() const { - return _font->getMaxFontWidth() >> 1; + return _sjisWidth; } int SJISFont::getCharWidth(uint16 c) const { - return _font->getCharWidth(c) >> 1; + if (_screen->isSJISChar(c)) + return _sjisWidth; + else + return _asciiWidth; } void SJISFont::setColorMap(const uint8 *src) { diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h index 99459214ca..82862fcbf7 100644 --- a/engines/kyra/screen.h +++ b/engines/kyra/screen.h @@ -44,6 +44,7 @@ namespace Kyra { typedef Common::Functor0<void> UpdateFunctor; class KyraEngine_v1; +class Screen; struct ScreenDim { uint16 sx; @@ -176,7 +177,7 @@ private: */ class SJISFont : public Font { public: - SJISFont(Graphics::FontSJIS *font, const uint8 invisColor, bool is16Color); + SJISFont(Screen *s, Graphics::FontSJIS *font, const uint8 invisColor, bool is16Color, bool outlineSize); ~SJISFont() { unload(); } bool usesOverlay() const { return true; } @@ -195,6 +196,10 @@ private: Graphics::FontSJIS *_font; const uint8 _invisColor; const bool _is16Color; + + const Screen *_screen; + int _sjisWidth, _asciiWidth; + int _fontHeight; }; /** @@ -421,6 +426,8 @@ public: const ScreenDim *_curDim; + bool isSJISChar(uint16 ch) const; + // shape handling uint8 *encodeShape(int x, int y, int w, int h, int flags); @@ -492,8 +499,6 @@ protected: void copyOverlayRegion(int x, int y, int x2, int y2, int w, int h, int srcPage, int dstPage); // font/text specific - bool isSJISChar(uint16 ch) const; - bool requiresSJISFont(const char *s) const; uint16 fetchChar(const char *&s) const; void drawChar(uint16 c, int x, int y); |