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 class WinResources;
00032 }
00033 
00034 namespace Graphics {
00035 
00036 struct WinFontDirEntry {
00037     WinFontDirEntry() : points(0) {}
00038     WinFontDirEntry(const Common::String &name, uint16 p) : faceName(name), points(p) {}
00039 
00040     // This is really just a simple identifier to match a directory entry with
00041     // If need-be, we can add other things to check such as italics and strikethrough, etc.
00042     Common::String faceName;
00043     uint16 points;
00044 };
00045 
00046 class WinFont : public Font {
00047 public:
00048     WinFont();
00049     ~WinFont();
00050 
00056     bool loadFromFON(const Common::String &fileName, const WinFontDirEntry &dirEntry = WinFontDirEntry());
00057 
00059     bool loadFromFNT(const Common::String &fileName);
00060 
00062     void close();
00063 
00064     // Font API
00065     int getFontHeight() const { return _pixHeight; }
00066     int getMaxCharWidth() const { return _maxWidth; }
00067     int getCharWidth(uint32 chr) const;
00068     void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const;
00069 
00070 private:
00071     bool loadFromEXE(Common::WinResources *exe, 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; charWidth = 0; offset = 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 30 2020 05:01:01 for ResidualVM by doxygen 1.7.1
curved edge   curved edge