From 6492c00a3ad24c16ef77e837c478bbc1b4c1e1bb Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 11 Oct 2009 11:28:43 +0000 Subject: Revert changes to graphics/sjis.h in r44709. svn-id: r44904 --- engines/kyra/screen.cpp | 43 +++++++++++++++---------------------------- engines/kyra/screen.h | 11 ++++++++--- graphics/sjis.h | 21 ++++++--------------- 3 files changed, 29 insertions(+), 46 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 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); diff --git a/graphics/sjis.h b/graphics/sjis.h index 87882e2fae..14a5187914 100644 --- a/graphics/sjis.h +++ b/graphics/sjis.h @@ -72,19 +72,12 @@ public: /** * Enable outline drawing. + * + * After changing outline state, getFontHeight and getMaxFontWidth / getCharWidth might return + * different values! */ virtual void enableOutline(bool enable) {} - /** - * Toggle values returned by getFontHeight and getMaxFontWidth / getCharWidth. - * These methods have to return different values when emulating PC-98 text mode. - * We cannot simply match this with enableOutline(), since there are situations - * where outlines get disabled in graphic mode, too. In these admittedly rare - * cases (Kyra 1: Brynn's note, Kyra 2: spell book) the values returned by - * getFontHeight and getMaxFontWidth / getCharWidth have to remain the same. - */ - virtual void toggleCharSize(bool textMode) {} - /** * Returns the height of the font. */ @@ -129,13 +122,12 @@ public: */ class FontSJIS16x16 : public FontSJIS { public: - FontSJIS16x16() : _outlineEnabled(false), _pc98TextModeCharSize(false) {} + FontSJIS16x16() : _outlineEnabled(false) {} void enableOutline(bool enable) { _outlineEnabled = enable; } - void toggleCharSize(bool textMode) { _pc98TextModeCharSize = textMode; } - uint getFontHeight() const { return _pc98TextModeCharSize ? 16 : 18; } - uint getMaxFontWidth() const { return _pc98TextModeCharSize ? 16 : 18; } + uint getFontHeight() const { return _outlineEnabled ? 18 : 16; } + uint getMaxFontWidth() const { return _outlineEnabled ? 18 : 16; } virtual void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2) const; @@ -148,7 +140,6 @@ private: protected: bool _outlineEnabled; - bool _pc98TextModeCharSize; virtual const uint16 *getCharData(uint16 c) const = 0; }; -- cgit v1.2.3