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