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