2009-06-11 20:31:36 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "graphics/font.h"
|
|
|
|
|
|
|
|
namespace Draci {
|
|
|
|
|
2009-06-14 16:21:44 +00:00
|
|
|
const Common::String kFontSmall("Small.fon");
|
|
|
|
const Common::String kFontBig("Big.fon");
|
|
|
|
|
2009-06-12 09:45:12 +00:00
|
|
|
/**
|
|
|
|
* Represents the game's fonts. See docs for setFont() for font format details.
|
|
|
|
*/
|
|
|
|
|
2009-06-14 16:33:20 +00:00
|
|
|
class Font {
|
2009-06-11 20:31:36 +00:00
|
|
|
|
|
|
|
public:
|
2009-06-14 16:33:20 +00:00
|
|
|
Font(const Common::String &filename);
|
|
|
|
~Font();
|
2009-06-14 16:21:44 +00:00
|
|
|
bool setFont(const Common::String &filename);
|
2009-06-11 20:31:36 +00:00
|
|
|
uint8 getFontHeight() const { return _fontHeight; };
|
|
|
|
uint8 getMaxCharWidth() const { return _maxCharWidth; };
|
|
|
|
uint8 getCharWidth(byte chr) const;
|
|
|
|
void drawChar(Graphics::Surface *dst, uint8 chr, int tx, int ty) const;
|
2009-06-12 10:25:05 +00:00
|
|
|
void drawString(Graphics::Surface *dst, Common::String &str,
|
2009-06-11 20:31:36 +00:00
|
|
|
int x, int y, int spacing = 0) const;
|
|
|
|
int getStringWidth(Common::String &str, int spacing = 0) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint8 _fontHeight;
|
|
|
|
uint8 _maxCharWidth;
|
2009-06-12 09:45:12 +00:00
|
|
|
|
|
|
|
/** Pointer to an array of individual char widths */
|
2009-06-11 20:31:36 +00:00
|
|
|
uint8 *_charWidths;
|
2009-06-12 09:45:12 +00:00
|
|
|
|
|
|
|
/** Pointer to a raw byte array representing font pixels stored row-wise */
|
2009-06-11 20:31:36 +00:00
|
|
|
byte *_charData;
|
|
|
|
|
2009-06-12 09:45:12 +00:00
|
|
|
/** Number of glyphs in the font */
|
2009-06-11 20:31:36 +00:00
|
|
|
static const unsigned int kCharNum = 138;
|
|
|
|
|
2009-06-14 13:32:21 +00:00
|
|
|
/** Chars are indexed from the space character so this should be subtracted
|
|
|
|
* to get the index of a glyph
|
|
|
|
*/
|
2009-06-11 20:31:36 +00:00
|
|
|
static const unsigned int kCharIndexOffset = 32;
|
|
|
|
|
2009-06-12 09:45:12 +00:00
|
|
|
/** Internal function for freeing fonts when destructing/loading another */
|
2009-06-11 20:31:36 +00:00
|
|
|
void freeFont();
|
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Draci
|