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 
67  int stringWidth(const Common::String &msg) const;
68 
76  kWidthInPixels,
77  kWidthInChars
78  };
79 
89  bool getLine(Common::String &s, int maxWidth, Common::String &line, int &width,
90  LINE_WIDTH_TYPE widthType = kWidthInPixels) const;
91 
95  void drawString(BaseSurface *s, const Common::String &msg, const Common::Point &pt) const;
96 
100  int drawChar(BaseSurface *s, char c, Common::Point &pt) const;
101 
102 };
103 
104 class AmazonFont : public Font {
105 private:
109  void load(const int *fontIndex, const byte *fontData);
110 public:
114  AmazonFont(const int *fontIndex, const byte *fontData) : Font(32) {
115  load(fontIndex, fontData);
116  }
117 
118 };
119 
120 class MartianFont : public Font {
121 private:
125  void loadFromStream(Common::SeekableReadStream &s);
126  void loadFromData(size_t count, const byte *widths, const int *offsets, const byte *data);
127 public:
131  MartianFont(int height, Common::SeekableReadStream &s);
132  MartianFont(int height, size_t count, const byte *widths, const int *offsets, const byte *data);
133 };
134 
135 class MartianBitFont : public Font {
136 public:
140  MartianBitFont(size_t count, const byte *data);
141 };
142 
143 
144 class FontManager {
145 public:
146  FontVal _charSet;
147  FontVal _charFor;
148  int _printMaxX;
149  Font *_font1;
150  Font *_font2;
151  Font *_bitFont;
152 public:
156  FontManager();
157 
161  void load(Font *font1, Font *font2, Font *bitFont);
162 };
163 
164 } // End of namespace Access
165 
166 #endif /* ACCESS_FONT_H */
Definition: font.h:120
Definition: str.h:59
Definition: font.h:104
Definition: stream.h:745
Definition: asurface.h:42
Definition: font.h:135
Definition: font.h:144
Definition: rect.h:144
AmazonFont(const int *fontIndex, const byte *fontData)
Definition: font.h:114
Definition: font.h:40
Definition: access.h:62
Definition: font.h:33
LINE_WIDTH_TYPE
Definition: font.h:75