ScummVM API documentation
winfont.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef GRAPHICS_WINFONT_H
23#define GRAPHICS_WINFONT_H
24
25#include "common/str.h"
26#include "common/path.h"
27#include "graphics/font.h"
28
29namespace Common {
30class SeekableReadStream;
31class WinResources;
32}
33
34namespace Graphics {
35
37 WinFontDirEntry() : points(0) {}
38 WinFontDirEntry(const Common::String &name, uint16 p) : faceName(name), points(p) {}
39
40 // This is really just a simple identifier to match a directory entry with
41 // If need-be, we can add other things to check such as italics and strikethrough, etc.
42 Common::String faceName;
43 uint16 points;
44};
45
46class WinFont : public Font {
47public:
48 WinFont();
49 ~WinFont();
50
56 bool loadFromFON(const Common::Path &fileName, const WinFontDirEntry &dirEntry = WinFontDirEntry());
58
60 bool loadFromFNT(const Common::Path &fileName);
61
63 void close();
64
65 // Font API
66 int getFontHeight() const override { return _pixHeight; } //< pixels, not points - for points, see getFontSizeInPointsAtDPI()
67 int getFontAscent() const override { return _ascent; }
68 int getMaxCharWidth() const override { return _maxWidth; }
69 Common::String getName() const { return _name; }
70 int getCharWidth(uint32 chr) const override;
71 void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const override;
72 int getStyle() const;
73
74 int getFontSizeInPointsAtDPI(const int dpi) const;
75
76 static WinFont *scaleFont(const WinFont *src, int newSize);
77private:
78 bool loadFromEXE(Common::WinResources *exe, const Common::Path &fileName, const WinFontDirEntry &dirEntry);
79
80 uint32 getFontIndex(Common::SeekableReadStream &stream, const WinFontDirEntry &dirEntry);
81 Common::String getFONFontName(Common::SeekableReadStream &stream);
83 char indexToCharacter(uint16 index) const;
84 uint16 characterToIndex(uint32 character) const;
85
86 uint16 _pixHeight;
87 uint16 _maxWidth;
88 uint16 _ascent;
89 uint16 _sizeInPoints;
90 uint16 _dpi;
91 byte _firstChar;
92 byte _lastChar;
93 byte _defaultChar;
94 bool _italic;
95 bool _strikethrough;
96 bool _underline;
97 uint16 _weight;
98 Common::String _name;
99
100 enum {
101 kFontStyleRegular,
102 kFontStyleBold = 1,
103 kFontStyleItalic = 2,
104 kFontStyleUnderline = 4,
105 };
106
107 uint16 _glyphCount;
108 struct GlyphEntry {
109 GlyphEntry() : charWidth(0), offset(0), bitmap(nullptr) {}
110 ~GlyphEntry() { delete[] bitmap; }
111
112 uint16 charWidth;
113 uint32 offset;
114 byte *bitmap;
115 } *_glyphs;
116};
117
118} // End of namespace Graphics
119
120#endif
Definition: path.h:52
Definition: stream.h:745
Definition: str.h:59
Definition: winexe.h:110
Definition: font.h:83
Definition: winfont.h:46
int getMaxCharWidth() const override
Definition: winfont.h:68
bool loadFromFNT(const Common::Path &fileName)
int getFontHeight() const override
Definition: winfont.h:66
int getFontAscent() const override
Definition: winfont.h:67
bool loadFromFON(const Common::Path &fileName, const WinFontDirEntry &dirEntry=WinFontDirEntry())
void drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const override
int getCharWidth(uint32 chr) const override
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: surface.h:67
Definition: winfont.h:36