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 LASTEXPRESS_FONT_H
23 #define LASTEXPRESS_FONT_H
24 
25 /*
26  Font format (FONT.DAT)
27 
28  uint16 {40} - Palette data
29  byte {200} - Character map
30  uint16 {2} - Number of glyphs
31 
32  // For each glyph
33  byte {18*8} - Glyph data
34 
35  byte {x} - Unknown data (probably just garbage)
36 */
37 
38 #include "common/str.h"
39 #include "graphics/surface.h"
40 
41 namespace Common {
42 class SeekableReadStream;
43 struct Rect;
44 }
45 
46 namespace LastExpress {
47 
48 class Font {
49 public:
50  Font();
51  ~Font();
52 
53  bool load(Common::SeekableReadStream *stream);
54  Common::Rect drawString(Graphics::Surface *surface, int16 x, int16 y, Common::String str);
55  Common::Rect drawString(Graphics::Surface *surface, int16 x, int16 y, const uint16 *str, uint16 length);
56 
57 private:
58  static const uint32 _paletteSize = 0x10;
59  static const uint32 _charMapSize = 0x200;
60  static const uint32 _charHeight = 16;
61 
62  void reset();
63 
64  uint16 getCharGlyph(uint16 c) const;
65  byte *getGlyphImg(uint16 g);
66  uint8 getGlyphWidth(uint16 g);
67  byte *getCharImg(uint16 c);
68  uint8 getCharWidth(uint16 c) const;
69  uint16 getStringWidth(Common::String str) const;
70  uint16 getStringWidth(const uint16 *str, uint16 length) const;
71  void drawChar(Graphics::Surface *surface, int16 x, int16 y, uint16 c);
72 
73  // Font data
74  uint16 _palette[_paletteSize];
75  uint8 _charMap[_charMapSize];
76  uint16 _numGlyphs;
77  byte *_glyphs;
78  uint8 *_glyphWidths;
79 };
80 
81 } // End of namespace LastExpress
82 
83 #endif // LASTEXPRESS_FONT_H
Definition: font.h:48
Definition: str.h:59
Definition: surface.h:66
Definition: rect.h:144
Definition: stream.h:745
Definition: animation.h:45
Definition: algorithm.h:29