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 DRACI_FONT_H
23 #define DRACI_FONT_H
24 
25 #include "graphics/font.h"
26 #include "common/path.h"
27 
28 namespace Draci {
29 
30 extern const char * const kFontSmall;
31 extern const char * const kFontBig;
32 
33 class Surface;
34 
40 enum {
41  kFontColor1 = 2,
42  kFontColor2 = 0,
43  kFontColor3 = 3,
44  kFontColor4 = 4,
45  kOverFontColor = 255,
46  kTitleColor = 255,
47  kLineActiveColor = 254,
48  kLineInactiveColor = 255
49 };
50 
54 class Font {
55 
56 public:
57  Font(const Common::Path &filename);
58  ~Font();
59 
60  bool loadFont(const Common::Path &filename);
61  uint8 getFontHeight() const { return _fontHeight; }
62  uint8 getMaxCharWidth() const { return _maxCharWidth; }
63  uint8 getCharWidth(byte chr) const;
64  void drawChar(Surface *dst, uint8 chr, int tx, int ty, int with_color) const;
65 
66  void drawString(Surface *dst, const byte *str, uint len, int x, int y, int with_color,
67  int spacing, bool markDirty) const;
68  void drawString(Surface *dst, const Common::String &str,
69  int x, int y, int with_color, int spacing, bool markDirty) const;
70 
71  uint getStringWidth(const Common::String &str, int spacing) const;
72  uint getStringHeight(const Common::String &str) const;
73  uint getLineWidth(const Common::String &str, uint startIndex, int spacing) const;
74 
75 private:
76  uint8 _fontHeight;
77  uint8 _maxCharWidth;
78 
80  uint8 *_charWidths;
81 
83  byte *_charData;
84 
86  static const uint kCharNum = 138;
87 
92  static const uint kCharIndexOffset = 32;
93 
95  void freeFont();
96 };
97 
98 } // End of namespace Draci
99 
100 #endif // DRACI_FONT_H
Definition: font.h:54
Definition: str.h:59
Definition: path.h:52
Definition: surface.h:31
Definition: animation.h:30