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 
31 namespace Access {
32 
33 struct FontVal {
34 public:
35  int _lo, _hi;
36 
37  FontVal() { _lo = _hi = 0; }
38 };
39 
40 class Font {
41 protected:
42  byte _firstCharIndex;
43  int _bitWidth;
44  int _height;
46 protected:
50  Font(byte firstCharIndex);
51 public:
52  static byte _fontColors[4];
53 public:
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 
110 class AmazonFont : public Font {
111 private:
115  void load(const int *fontIndex, const byte *fontData);
116 public:
120  AmazonFont(const int *fontIndex, const byte *fontData) : Font(32) {
121  load(fontIndex, fontData);
122  }
123 
124 };
125 
126 class MartianFont : public Font {
127 private:
131  void loadFromStream(Common::SeekableReadStream &s);
132  void loadFromData(size_t count, const byte *widths, const int *offsets, const byte *data);
133 public:
137  MartianFont(int height, Common::SeekableReadStream &s);
138  MartianFont(int height, size_t count, const byte *widths, const int *offsets, const byte *data);
139 };
140 
141 class MartianBitFont : public Font {
142 public:
146  MartianBitFont(size_t count, const byte *data);
147 };
148 
149 
150 class FontManager {
151 public:
152  FontVal _charSet;
153  FontVal _charFor;
154  int _printMaxX;
155 
157  const Font *_font1;
158  const Font *_font2;
159  const Font *_bitFont;
160 
163 public:
167  FontManager();
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:126
Definition: str.h:59
const Font * _font1
Definition: font.h:157
Definition: font.h:110
Definition: stream.h:745
Definition: asurface.h:42
Definition: font.h:141
void push_back(const T &element)
Definition: array.h:181
Definition: font.h:150
Definition: rect.h:144
AmazonFont(const int *fontIndex, const byte *fontData)
Definition: font.h:120
Definition: font.h:40
Definition: access.h:62
Definition: font.h:33
Common::Array< const Font * > _fonts
Definition: font.h:162
LINE_WIDTH_TYPE
Definition: font.h:81