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

winfont.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM 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 GRAPHICS_WINFONT_H
00024 #define GRAPHICS_WINFONT_H
00025 
00026 #include "common/str.h"
00027 #include "graphics/font.h"
00028 
00029 namespace Common {
00030 class SeekableReadStream;
00031 }
00032 
00033 namespace Graphics {
00034 
00035 struct WinFontDirEntry {
00036     WinFontDirEntry() {}
00037     WinFontDirEntry(const Common::String &name, uint16 p) : faceName(name), points(p) {}
00038 
00039     // This is really just a simple identifier to match a directory entry with
00040     // If need-be, we can add other things to check such as italics and strikethrough, etc.
00041     Common::String faceName;
00042     uint16 points;
00043 };
00044 
00045 class WinFont : public Font {
00046 public:
00047     WinFont();
00048     ~WinFont();
00049 
00055     bool loadFromFON(const Common::String &fileName, const WinFontDirEntry &dirEntry = WinFontDirEntry());
00056 
00058     bool loadFromFNT(const Common::String &fileName);
00059 
00061     void close();
00062 
00063     // Font API
00064     int getFontHeight() const { return _pixHeight; }
00065     int getMaxCharWidth() const { return _maxWidth; }
00066     int getCharWidth(uint32 chr) const;
00067     void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const;
00068 
00069 private:
00070     bool loadFromPE(const Common::String &fileName, const WinFontDirEntry &dirEntry);
00071     bool loadFromNE(const Common::String &fileName, const WinFontDirEntry &dirEntry);
00072 
00073     uint32 getFontIndex(Common::SeekableReadStream &stream, const WinFontDirEntry &dirEntry);
00074     bool loadFromFNT(Common::SeekableReadStream &stream);
00075     char indexToCharacter(uint16 index) const;
00076     uint16 characterToIndex(uint32 character) const;
00077 
00078     uint16 _pixHeight;
00079     uint16 _maxWidth;
00080     byte _firstChar;
00081     byte _lastChar;
00082     byte _defaultChar;
00083 
00084     uint16 _glyphCount;
00085     struct GlyphEntry {
00086         GlyphEntry() { bitmap = 0; }
00087         ~GlyphEntry() { delete[] bitmap; }
00088 
00089         uint16 charWidth;
00090         uint32 offset;
00091         byte *bitmap;
00092     } *_glyphs;
00093 };
00094 
00095 } // End of namespace Graphics
00096 
00097 #endif


Generated on Sat May 18 2019 05:01:30 for ResidualVM by doxygen 1.7.1
curved edge   curved edge