ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

engines/grim/font.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GRIM_FONT_H
00024 #define GRIM_FONT_H
00025 
00026 #include "engines/grim/pool.h"
00027 
00028 namespace Common {
00029 class SeekableReadStream;
00030 }
00031 
00032 namespace Grim {
00033 
00034 class SaveGame;
00035 
00036 class Font : public PoolObject<Font> {
00037 public:
00038     Font();
00039     ~Font();
00040 
00041     static int32 getStaticTag() { return MKTAG('F', 'O', 'N', 'T'); }
00042 
00043     void load(const Common::String &filename, Common::SeekableReadStream *data);
00044 
00045     const Common::String &getFilename() const { return _filename; }
00046     int32 getKernedHeight() const { return _kernedHeight; }
00047     int32 getBaseOffsetY() const { return _baseOffsetY; }
00048     int32 getCharBitmapWidth(unsigned char c) const { return _charHeaders[getCharIndex(c)].bitmapWidth; }
00049     int32 getCharBitmapHeight(unsigned char c) const { return _charHeaders[getCharIndex(c)].bitmapHeight; }
00050     int32 getCharKernedWidth(unsigned char c) const { return _charHeaders[getCharIndex(c)].kernedWidth; }
00051     int32 getCharStartingCol(unsigned char c) const { return _charHeaders[getCharIndex(c)].startingCol; }
00052     int32 getCharStartingLine(unsigned char c) const { return _charHeaders[getCharIndex(c)].startingLine; }
00053     int32 getCharOffset(unsigned char c) const { return _charHeaders[getCharIndex(c)].offset; }
00054     const byte *getCharData(unsigned char c) const { return _fontData + (_charHeaders[getCharIndex(c)].offset); }
00055 
00056     const byte *getFontData() const { return _fontData; }
00057     uint32 getDataSize() const { return _dataSize; }
00058 
00059     int getKernedStringLength(const Common::String &text) const;
00060     int getBitmapStringLength(const Common::String &text) const;
00061     int getStringHeight(const Common::String &text) const;
00062 
00063     const void *getUserData() const { return _userData; }
00064     void setUserData(void *data) { _userData = data; }
00065 
00066     void saveState(SaveGame *state) const;
00067     void restoreState(SaveGame *state);
00068 
00069     static const uint8 emerFont[][13];
00070 private:
00071 
00072     uint16 getCharIndex(unsigned char c) const;
00073     struct CharHeader {
00074         int32 offset;
00075         int8  kernedWidth;
00076         int8  startingCol;
00077         int8  startingLine;
00078         int32 bitmapWidth;
00079         int32 bitmapHeight;
00080     };
00081 
00082     uint32 _numChars;
00083     uint32 _dataSize;
00084     uint32 _kernedHeight, _baseOffsetY;
00085     uint32 _firstChar, _lastChar;
00086     uint16 *_charIndex;
00087     CharHeader *_charHeaders;
00088     byte *_fontData;
00089     Common::String _filename;
00090     void *_userData;
00091 };
00092 
00093 } // end of namespace Grim
00094 
00095 #endif


Generated on Sat May 25 2019 05:00:45 for ResidualVM by doxygen 1.7.1
curved edge   curved edge