ScummVM API documentation
font.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 ACCESS_FONT_H
23#define ACCESS_FONT_H
24
25#include "common/scummsys.h"
26#include "common/array.h"
27#include "common/rect.h"
28#include "access/asurface.h"
29#include "access/data.h"
30
31namespace Access {
32
33struct FontVal {
34public:
35 int _lo, _hi;
36
37 FontVal() { _lo = _hi = 0; }
38};
39
40class Font {
41protected:
42 byte _firstCharIndex;
43 int _bitWidth;
44 int _height;
46protected:
50 Font(byte firstCharIndex);
51public:
52 static byte _fontColors[4];
53public:
57 virtual ~Font();
58
62 int charWidth(char c) const;
63
68 int stringWidth(const Common::String &msg) const;
69
73 virtual int stringHeight(const Common::String &msg) const;
74
82 kWidthInPixels,
83 kWidthInChars
84 };
85
95 bool getLine(Common::String &s, int maxWidth, Common::String &line, int &width,
96 LINE_WIDTH_TYPE widthType = kWidthInPixels) const;
97
101 void drawString(BaseSurface *s, const Common::String &msg, const Common::Point &pt) const;
102
106 int drawChar(BaseSurface *s, char c, Common::Point &pt) const;
107
108};
109
110class AmazonFont : public Font {
111private:
115 void load(const int *fontIndex, const byte *fontData);
116public:
120 AmazonFont(const int *fontIndex, const byte *fontData) : Font(32) {
121 load(fontIndex, fontData);
122 }
123
124};
125
126class MartianFont : public Font {
127private:
131 void loadFromStream(Common::SeekableReadStream &s);
132 void loadFromData(size_t count, const byte *widths, const int *offsets, const byte *data);
133public:
138 MartianFont(int height, size_t count, const byte *widths, const int *offsets, const byte *data);
139};
140
141class MartianBitFont : public Font {
142public:
146 MartianBitFont(size_t count, const byte *data);
147};
148
149
151public:
152 FontVal _charSet;
153 FontVal _charFor;
154 int _printMaxX;
155
157 const Font *_font1;
158 const Font *_font2;
159 const Font *_bitFont;
160
163public:
168
172 void load(const Font *font1, const Font *font2, const Font *bitFont);
173
174 void addFont(const Font *font) {
175 _fonts.push_back(font);
176 }
177
178 const Font *getFont(int num) {
179 return _fonts[num];
180 }
181};
182
183} // End of namespace Access
184
185#endif /* ACCESS_FONT_H */
Definition: font.h:110
AmazonFont(const int *fontIndex, const byte *fontData)
Definition: font.h:120
Definition: asurface.h:42
Definition: font.h:40
int drawChar(BaseSurface *s, char c, Common::Point &pt) const
int charWidth(char c) const
void drawString(BaseSurface *s, const Common::String &msg, const Common::Point &pt) const
int stringWidth(const Common::String &msg) const
LINE_WIDTH_TYPE
Definition: font.h:81
virtual int stringHeight(const Common::String &msg) const
Font(byte firstCharIndex)
virtual ~Font()
bool getLine(Common::String &s, int maxWidth, Common::String &line, int &width, LINE_WIDTH_TYPE widthType=kWidthInPixels) const
Definition: font.h:150
Common::Array< const Font * > _fonts
Definition: font.h:162
const Font * _font1
Definition: font.h:157
void load(const Font *font1, const Font *font2, const Font *bitFont)
Definition: font.h:141
MartianBitFont(size_t count, const byte *data)
Definition: font.h:126
MartianFont(int height, Common::SeekableReadStream &s)
Definition: stream.h:745
Definition: str.h:59
Definition: access.h:62
Definition: font.h:33
Definition: rect.h:144