ScummVM API documentation
font_manager.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 ULTIMA8_GFX_FONTS_FONTMANAGER_H
23 #define ULTIMA8_GFX_FONTS_FONTMANAGER_H
24 
25 #include "common/hashmap.h"
26 #include "common/path.h"
27 #include "graphics/font.h"
28 
29 namespace Ultima {
30 namespace Ultima8 {
31 
32 class Font;
33 
34 // This is TTF_Font struct
35 typedef struct _TTF_Font TTF_Font;
36 
37 class TTFont;
38 
39 
40 class FontManager {
41 private:
42  struct TTFId {
43  Common::Path _filename;
44  int _pointSize;
45  bool operator<(const TTFId &other) const {
46  return (_pointSize < other._pointSize ||
47  (_pointSize == other._pointSize &&
48  _filename < other._filename));
49  }
50  };
51 
52  struct TTFHash {
53  uint operator()(const TTFId &x) const {
54  // TODO: See if something better can be used as a hash key
55  int64 val = (int64)&x;
56  return (uint)val;
57  }
58  };
59  struct TTFEqual {
60  bool operator()(const TTFId &x, const TTFId &y) const {
61  return x._filename == y._filename && x._pointSize == y._pointSize;
62  }
63  };
64 
66  TTFFonts _ttfFonts;
67 
70  Graphics::Font *getTTF_Font(const Common::Path &filename, int pointsize, bool antialiasing);
71 
73  void setOverride(unsigned int fontnum, Font *newFont);
74 
75  Common::Array<Font *> _overrides;
76 
77  Common::Array<Font *> _ttFonts;
78 
79  static FontManager *_fontManager;
80 public:
81  FontManager();
82  ~FontManager();
83 
84  static FontManager *get_instance() {
85  return _fontManager;
86  }
87 
91  Font *getGameFont(unsigned int fontnum,
92  bool allowOverride = false);
93 
95  Font *getTTFont(unsigned int ttfnum);
96 
104  bool addTTFOverride(unsigned int fontnum, const Common::Path &filename,
105  int pointsize, uint32 rgb, int bordersize,
106  bool SJIS = false);
107 
112  bool addJPOverride(unsigned int fontnum, unsigned int jpfont, uint32 rgb);
113 
115  bool loadTTFont(unsigned int ttfnum, const Common::Path &filename,
116  int pointsize, uint32 rgb, int bordersize);
117 
118  // Reset the game fonts
119  void resetGameFonts();
120 };
121 
122 } // End of namespace Ultima8
123 } // End of namespace Ultima // End of namespace Ultima8
124 
125 #endif
Definition: font.h:41
bool addJPOverride(unsigned int fontnum, unsigned int jpfont, uint32 rgb)
Definition: font.h:83
Definition: array.h:52
Font * getGameFont(unsigned int fontnum, bool allowOverride=false)
Definition: path.h:52
Definition: font_manager.h:40
Definition: detection.h:27
Font * getTTFont(unsigned int ttfnum)
get a TTF font (for non-game fonts)
bool addTTFOverride(unsigned int fontnum, const Common::Path &filename, int pointsize, uint32 rgb, int bordersize, bool SJIS=false)
bool loadTTFont(unsigned int ttfnum, const Common::Path &filename, int pointsize, uint32 rgb, int bordersize)
load a TTF (for non-game fonts)