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 MADS_FONT_H
23 #define MADS_FONT_H
24 
25 #include "common/scummsys.h"
26 #include "common/hashmap.h"
27 #include "common/endian.h"
28 #include "common/util.h"
29 #include "mads/msurface.h"
30 
31 namespace MADS {
32 
33 #define FONT_CONVERSATION "*FONTCONV.FF"
34 #define FONT_INTERFACE "*FONTINTR.FF"
35 #define FONT_MAIN "*FONTMAIN.FF"
36 #define FONT_MENU "*FONTMENU.FF" // Not in Rex (uses bitmap files for menu strings)
37 #define FONT_MISC "*FONTMISC.FF"
38 #define FONT_TELE "*FONTTELE.FF" // Not in Phantom
39 #define FONT_PHAN "*FONTPHAN.FF" // Phantom only
40 
41 enum SelectionMode {
42  SELMODE_UNSELECTED = 0, SELMODE_HIGHLIGHTED = 1, SELMODE_SELECTED = 2
43 };
44 
45 class MADSEngine;
46 
47 class Font {
48 private:
49  static uint8 _fontColors[4];
50  static MADSEngine *_vm;
52 public:
56  static void init(MADSEngine *vm);
57 
61  static void deinit();
62 
66  static Font *getFont(const Common::String &fontName);
67 private:
68  uint8 _maxWidth, _maxHeight;
69  uint8 *_charWidths;
70  uint16 *_charOffs;
71  uint8 *_charData;
72  Common::Path _filename;
73 
74  int getBpp(int charWidth);
75 
76  void setFont(const Common::Path &filename);
77 public:
78  Font();
79  Font(const Common::Path &filename);
80  virtual ~Font();
81 
82  void setColors(uint8 v1, uint8 v2, uint8 v3, uint8 v4);
83  void setColorMode(SelectionMode mode);
84 
85  int maxWidth() const { return _maxWidth; }
86  int getWidth(const Common::String &msg, int spaceWidth = -1);
87  int getHeight() const { return _maxHeight; }
88  int writeString(BaseSurface *surface, const Common::String &msg, const Common::Point &pt,
89  int spaceWidth = 0, int width = 0);
90 };
91 
92 } // End of namespace MADS
93 
94 #endif /* MADS_FONT_H */
Definition: msurface.h:54
Definition: str.h:59
static Font * getFont(const Common::String &fontName)
Definition: path.h:52
Definition: hashmap.h:85
static void init(MADSEngine *vm)
Definition: rect.h:45
Definition: mads.h:71
Definition: font.h:47
Definition: action.h:28
static void deinit()