Create base class FontSJIS16x16 for our own SJIS font.

svn-id: r42812
This commit is contained in:
Johannes Schickel 2009-07-26 14:16:51 +00:00
parent 997f7b9a3b
commit 712e0c80ea
2 changed files with 37 additions and 26 deletions

View File

@ -30,14 +30,8 @@
namespace Graphics {
bool FontTowns::loadFromStream(Common::ReadStream &stream) {
for (uint i = 0; i < (kFontRomSize / 2); ++i)
_fontData[i] = stream.readUint16BE();
return !stream.err();
}
template<typename Color>
void FontTowns::drawCharInternOutline(const uint16 *glyph, uint8 *dst, int pitch, Color c1, Color c2) const {
void FontSJIS16x16::drawCharInternOutline(const uint16 *glyph, uint8 *dst, int pitch, Color c1, Color c2) const {
uint32 outlineGlyph[18];
memset(outlineGlyph, 0, sizeof(outlineGlyph));
@ -72,7 +66,7 @@ void FontTowns::drawCharInternOutline(const uint16 *glyph, uint8 *dst, int pitch
}
template<typename Color>
void FontTowns::drawCharIntern(const uint16 *glyph, uint8 *dst, int pitch, Color c1) const {
void FontSJIS16x16::drawCharIntern(const uint16 *glyph, uint8 *dst, int pitch, Color c1) const {
for (int y = 0; y < 16; ++y) {
Color *lineBuf = (Color *)dst;
uint16 line = *glyph++;
@ -88,8 +82,8 @@ void FontTowns::drawCharIntern(const uint16 *glyph, uint8 *dst, int pitch, Color
}
}
void FontTowns::drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2) const {
const uint16 *glyphSource = _fontData + sjisToChunk(ch & 0xFF, ch >> 8) * 16;
void FontSJIS16x16::drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2) const {
const uint16 *glyphSource = getCharData(ch);
if (bpp == 1) {
if (!_outlineEnabled)
@ -106,7 +100,16 @@ void FontTowns::drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, ui
}
}
uint FontTowns::sjisToChunk(uint8 f, uint8 s) {
bool FontTowns::loadFromStream(Common::ReadStream &stream) {
for (uint i = 0; i < (kFontRomSize / 2); ++i)
_fontData[i] = stream.readUint16BE();
return !stream.err();
}
const uint16 *FontTowns::getCharData(uint16 ch) const {
uint8 f = ch & 0xFF;
uint8 s = ch >> 8;
// copied from scumm\charset.cpp
enum {
KANA = 0,
@ -188,7 +191,7 @@ uint FontTowns::sjisToChunk(uint8 f, uint8 s) {
}
debug(6, "Kanji: %c%c f 0x%x s 0x%x base 0x%x c %d p %d chunk %d cr %d index %d", f, s, f, s, base, c, p, chunk, cr, ((chunk_f + chunk) * 32 + (s - base)) + cr);
return ((chunk_f + chunk) * 32 + (s - base)) + cr;
return _fontData + (((chunk_f + chunk) * 32 + (s - base)) + cr) * 16;
}
} // end of namespace Graphics

View File

@ -87,19 +87,9 @@ public:
virtual void drawChar(void *dst, uint16 ch, int pitch, int bpp, uint32 c1, uint32 c2) const = 0;
};
/**
* FM-TOWNS ROM based SJIS compatible font.
*
* This is used in KYRA and SCI.
*/
class FontTowns : public FontSJIS {
class FontSJIS16x16 : public FontSJIS {
public:
FontTowns() : _outlineEnabled(false) {}
/**
* Loads the ROM data from the given read stream.
*/
bool loadFromStream(Common::ReadStream &stream);
FontSJIS16x16() : _outlineEnabled(false) {}
void enableOutline(bool enable) { _outlineEnabled = enable; }
@ -115,14 +105,32 @@ private:
template<typename Color>
void drawCharIntern(const uint16 *glyph, uint8 *dst, int pitch, Color c1) const;
bool _outlineEnabled;
protected:
virtual const uint16 *getCharData(uint16 c) const = 0;
};
/**
* FM-TOWNS ROM based SJIS compatible font.
*
* This is used in KYRA and SCI.
*/
class FontTowns : public FontSJIS16x16 {
public:
/**
* Loads the ROM data from the given read stream.
*/
bool loadFromStream(Common::ReadStream &stream);
private:
enum {
kFontRomSize = 262144
};
bool _outlineEnabled;
uint16 _fontData[kFontRomSize / 2];
static uint sjisToChunk(uint8 low, uint8 high);
const uint16 *getCharData(uint16 c) const;
};
// TODO: Consider adding support for PC98 ROM