diff options
author | Johannes Schickel | 2009-08-09 22:46:25 +0000 |
---|---|---|
committer | Johannes Schickel | 2009-08-09 22:46:25 +0000 |
commit | 518cb968b23bfb37cd1248c3a884d004a3309bba (patch) | |
tree | 9fca6e5ddf15803a93c4b7c824990e3bd6f815ba /engines/kyra/screen.h | |
parent | ad40f3b46eb898fac1447c7ceb55f312fbed8a8c (diff) | |
download | scummvm-rg350-518cb968b23bfb37cd1248c3a884d004a3309bba.tar.gz scummvm-rg350-518cb968b23bfb37cd1248c3a884d004a3309bba.tar.bz2 scummvm-rg350-518cb968b23bfb37cd1248c3a884d004a3309bba.zip |
Create a "Font" interface and create a "DOSFont" implementation for handling DOS version fonts.
svn-id: r43186
Diffstat (limited to 'engines/kyra/screen.h')
-rw-r--r-- | engines/kyra/screen.h | 87 |
1 files changed, 77 insertions, 10 deletions
diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h index f7fb389fe8..8455e5a8c4 100644 --- a/engines/kyra/screen.h +++ b/engines/kyra/screen.h @@ -56,15 +56,82 @@ struct ScreenDim { uint16 unkE; }; -struct Font { - uint8 *fontData; - uint8 *charWidthTable; - uint16 fontDescOffset; - uint16 charBitmapOffset; - uint16 charWidthTableOffset; - uint16 charHeightTableOffset; - - uint8 lastGlyph; +/** + * A class that handles KYRA fonts. + */ +class Font { +public: + virtual ~Font() {} + + /** + * Tries to load a file from the given stream + */ + virtual bool load(Common::SeekableReadStream &file) = 0; + + /** + * The font height. + */ + virtual int getHeight() const = 0; + + /** + * The font width, this is the maximal character + * width. + */ + virtual int getWidth() const = 0; + + /** + * Gets the width of a specific character. + */ + virtual int getCharWidth(uint8 c) const = 0; + + /** + * Sets a text palette map. The map contains 16 entries. + */ + virtual void setColorMap(const uint8 *src) = 0; + + /** + * Draws a specific character. + * + * TODO/FIXME: Replace this with a nicer API. Currently + * the user has to assure that the character fits. + * We use this API, since it's hard to assure dirty rect + * handling from outside Screen. + */ + virtual void drawChar(uint8 c, byte *dst, int pitch) const = 0; +}; + +/** + * Implementation of the Font interface for DOS fonts. + * + * TODO: Clean up the implementation. For example we might be able + * to not to keep the whole font in memory. + */ +class DOSFont : public Font { +public: + DOSFont(); + ~DOSFont() { unload(); } + + bool load(Common::SeekableReadStream &file); + int getHeight() const { return _height; } + int getWidth() const { return _width; } + int getCharWidth(uint8 c) const; + void setColorMap(const uint8 *src) { _colorMap = src; } + void drawChar(uint8 c, byte *dst, int pitch) const; + +private: + void unload(); + + const uint8 *_colorMap; + + uint8 *_data; + + int _width, _height; + + uint8 _numGlyphs; + + uint8 *_widthTable; + uint8 *_heightTable; + uint16 *_bitmapOffsets; }; /** @@ -382,7 +449,7 @@ protected: Common::Array<Palette *> _palettes; Palette *_internFadePalette; - Font _fonts[FID_NUM]; + Font *_fonts[FID_NUM]; uint8 _textColorsMap[16]; uint8 *_decodeShapeBuffer; |