ScummVM API documentation
macfontmanager.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 GRAPHICS_MACGUI_MACFONTMANAGER_H
23#define GRAPHICS_MACGUI_MACFONTMANAGER_H
24
25#include "common/language.h"
26#include "graphics/fonts/bdf.h"
27#include "graphics/fontman.h"
28
29#ifdef USE_FREETYPE2
30#include "graphics/fonts/ttf.h"
31#endif
32
33namespace Common {
34 class SeekableReadStream;
35 class MacResManager;
36}
37
38namespace Graphics {
39
40struct TTFMap {
41 const char *ttfName;
42 uint16 slant;
43};
44
45class MacFONTFont;
46class MacFontFamily;
47
48enum {
49 kMacFontNonStandard = -1,
50 kMacFontSystem = 0,
51 kMacFontApplication = 1,
52
53 kMacFontNewYork = 2,
54 kMacFontGeneva = 3,
55 kMacFontMonaco = 4,
56 kMacFontVenice = 5,
57 kMacFontLondon = 6,
58 kMacFontAthens = 7,
59 kMacFontSanFrancisco = 8,
60 kMacFontToronto = 9,
61 kMacFontCairo = 11,
62 kMacFontLosAngeles = 12,
63 kMacFontZapfDingbats = 13,
64 kMacFontBookman = 14,
65 kMacFontHelveticaNarrow = 15,
66 kMacFontPalatino = 16,
67 kMacFontZapfChancery = 18,
68 kMacFontTimes = 20,
69 kMacFontHelvetica = 21,
70 kMacFontCourier = 22,
71 kMacFontSymbol = 23,
72 kMacFontTaliesin = 24,
73 kMacFontAvantGarde = 33,
74 kMacFontNewCenturySchoolbook = 34,
75 kMacFontChicago = 16383,
76
77 kMacFontOsaka = 16384,
78 kMacFontBookMinchoM = 16396,
79 kMacFontMonoGothic = 16433,
80 kMacFontMonoMing = 16435,
81 kMacFontOsakaMono = 16436,
82 kMacFontMediumGothic = 16640,
83 kMacFontMing = 16641,
84 kMacFontHeiseiMincho = 16700,
85 kMacFontHeiseiKakuGothic = 16701
86};
87
88enum {
89 kMacFontRegular,
90 kMacFontBold = 1,
91 kMacFontItalic = 2,
92 kMacFontUnderline = 4,
93 kMacFontOutline = 8,
94 kMacFontShadow = 16,
95 kMacFontCondense = 32,
96 kMacFontExtend = 64
97};
98
99class Font;
100
101struct FontInfo {
102 Common::Language lang;
103 Common::CodePage encoding;
104 int aliasForId;
105 Common::String name;
106
107 FontInfo() : lang(Common::UNK_LANG), encoding(Common::kCodePageInvalid), aliasForId(-1) {}
108};
109
110class MacFont {
111public:
112 MacFont(int id = kMacFontSystem, int size = 12, int slant = kMacFontRegular) {
113 _id = id;
114 _size = size ? size : 12;
115 _slant = slant;
116 _fallback = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont);
117 _fallbackName = Common::String(((const BdfFont *)_fallback)->getFamilyName());
118 _generated = false;
119 _truetype = false;
120 _font = NULL;
121 }
122
123 int getId() const { return _id; };
124 void setId(int id) { _id = id; }
125 int getSize() const { return _size; }
126 int getSlant() const { return _slant; }
127 Common::String getName() const { return _name; }
128 void setName(Common::String &name) { setName(name.c_str()); }
129 void setName(const char *name);
130 const Graphics::Font *getFallback() const { return _fallback; }
131 bool isGenerated() const { return _generated; }
132 void setGenerated(bool gen) { _generated = gen; }
133 bool isTrueType() const { return _truetype; }
134 Font *getFont() const { return _font; }
135 void setFont(Font *font, bool truetype) { _font = font; _truetype = truetype; }
136 void setFallback(const Font *font, Common::String name = "");
137 Common::String getFallbackName() const { return _fallbackName; }
138
139private:
140 int _id;
141 int _size;
142 int _slant;
143 bool _truetype;
144 Common::String _name;
145 const Graphics::Font *_fallback;
146 Common::String _fallbackName;
147
148 bool _generated;
149 Font *_font;
150};
151
153public:
154 MacFontManager(uint32 mode, Common::Language language);
156
157 void setLocalizedFonts();
158
163 bool hasBuiltInFonts() { return _builtInFonts; }
170 const Font *getFont(MacFont *macFont);
171 const Font *getFont(MacFont macFont);
172
179 const Common::String getFontName(uint16 id, int size, int slant = kMacFontRegular, bool tryGen = false);
180 const Common::String getFontName(const MacFont &font);
181 int getFontIdByName(Common::String name);
182
183 Common::Language getFontLanguage(uint16 id);
184 Common::CodePage getFontEncoding(uint16 id);
185 int getFontAliasForId(uint16 id);
186 Common::String getFontName(uint16 id);
187
188 void loadFonts(Common::SeekableReadStream *stream);
189 void loadFonts(const Common::Path &fileName);
190 void loadMacFont(Common::MacResManager *fontFile, const Common::String &family, Common::SeekableReadStream *fond);
191 void loadFonts(Common::MacResManager *fontFile);
192 void loadWindowsFont(const Common::Path &fileName);
193
199 int registerFontName(Common::String name, int preferredId = -1);
200
201 void forceBuiltinFonts() { _builtInFonts = true; }
202 int parseSlantFromName(const Common::String &name);
203 Common::String getNameFromSlant(int slantVal);
204
205 const Common::Array<MacFontFamily *> &getFontFamilies() { return _fontFamilies; }
206
207 void printFontRegistry(int debugLevel, uint32 channel);
208
209 int registerTTFFont(const Graphics::TTFMap ttfList[]);
210
211 int getFamilyId(int newId, int newSlant);
212
213#ifdef USE_FREETYPE2
219 void setTTFRenderMode(TTFRenderMode mode) { _ttfRenderMode = mode; }
220 TTFRenderMode getTTFRenderMode() const { return _ttfRenderMode; }
221#endif
222
223private:
224 void loadFontsBDF();
225 void loadFonts();
226 void loadJapaneseFonts();
227
228 void generateFontSubstitute(MacFont &macFont);
229 void generateFONTFont(MacFont &toFont, MacFont &fromFont);
230
231#ifdef USE_FREETYPE2
232 void generateTTFFont(MacFont &toFront, Common::SeekableReadStream *stream);
233 TTFRenderMode _ttfRenderMode = Graphics::kTTFRenderModeMonochrome;
234#endif
235
236private:
237 bool _builtInFonts;
238 bool _japaneseFontsLoaded;
239 uint32 _mode;
240 Common::Language _language;
243 Common::Array<MacFontFamily *> _fontFamilies;
244
247
248 int parseFontSlant(Common::String slant);
249
250 /* Unicode font */
252
254};
255
256} // End of namespace Graphics
257
258#endif
Definition: array.h:52
Definition: macresman.h:126
Definition: path.h:52
Definition: stream.h:745
Definition: str.h:59
Definition: bdf.h:60
Definition: font.h:83
Definition: macfont.h:165
Definition: macfont.h:34
Definition: macfontmanager.h:110
Definition: macfontmanager.h:152
int registerFontName(Common::String name, int preferredId=-1)
const Font * getFont(MacFont *macFont)
bool hasBuiltInFonts()
Definition: macfontmanager.h:163
const Common::String getFontName(uint16 id, int size, int slant=kMacFontRegular, bool tryGen=false)
Language
Definition: language.h:45
#define FontMan
Definition: fontman.h:135
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: macfontmanager.h:101
Definition: macfontmanager.h:40