2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2005-01-06 21:15:52 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-01-06 21:15:52 +00:00
|
|
|
*/
|
|
|
|
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "graphics/font.h"
|
2005-01-06 21:15:52 +00:00
|
|
|
#include "graphics/fontman.h"
|
|
|
|
|
2010-11-16 08:23:13 +00:00
|
|
|
DECLARE_SINGLETON(Graphics::FontManager);
|
2007-05-27 11:40:03 +00:00
|
|
|
|
2005-01-06 21:15:52 +00:00
|
|
|
namespace Graphics {
|
|
|
|
|
2010-11-16 08:23:13 +00:00
|
|
|
FORWARD_DECLARE_FONT(g_sysfont);
|
|
|
|
FORWARD_DECLARE_FONT(g_sysfont_big);
|
|
|
|
FORWARD_DECLARE_FONT(g_consolefont);
|
2005-10-08 21:11:45 +00:00
|
|
|
|
2009-12-09 16:44:48 +00:00
|
|
|
FontManager::FontManager() {
|
2009-12-09 17:05:23 +00:00
|
|
|
// This assert should *never* trigger, because
|
|
|
|
// FontManager is a singleton, thus there is only
|
2011-05-22 14:15:15 +00:00
|
|
|
// one instance of it per time. (g_sysfont gets
|
2009-12-09 17:05:23 +00:00
|
|
|
// reset to 0 in the desctructor of this class).
|
2011-05-22 14:15:15 +00:00
|
|
|
assert(g_sysfont == 0);
|
2010-11-16 08:23:13 +00:00
|
|
|
INIT_FONT(g_sysfont);
|
|
|
|
INIT_FONT(g_sysfont_big);
|
|
|
|
INIT_FONT(g_consolefont);
|
2005-10-08 21:11:45 +00:00
|
|
|
}
|
2005-01-06 21:15:52 +00:00
|
|
|
|
2009-12-09 16:44:48 +00:00
|
|
|
FontManager::~FontManager() {
|
|
|
|
delete g_sysfont;
|
2009-12-09 17:05:23 +00:00
|
|
|
g_sysfont = 0;
|
2009-12-09 16:44:48 +00:00
|
|
|
delete g_sysfont_big;
|
2009-12-09 17:05:23 +00:00
|
|
|
g_sysfont_big = 0;
|
2009-12-09 16:44:48 +00:00
|
|
|
delete g_consolefont;
|
2009-12-09 17:05:23 +00:00
|
|
|
g_consolefont = 0;
|
2005-01-06 21:15:52 +00:00
|
|
|
}
|
|
|
|
|
2010-06-28 15:17:10 +00:00
|
|
|
const struct {
|
|
|
|
const char *name;
|
|
|
|
FontManager::FontUsage id;
|
|
|
|
} builtinFontNames[] = {
|
|
|
|
{ "builtinConsole", FontManager::kConsoleFont },
|
|
|
|
{ "fixed5x8.bdf", FontManager::kConsoleFont },
|
|
|
|
{ "fixed5x8-iso-8859-1.bdf", FontManager::kConsoleFont },
|
|
|
|
{ "fixed5x8-ascii.bdf", FontManager::kConsoleFont },
|
|
|
|
{ "clR6x12.bdf", FontManager::kGUIFont },
|
|
|
|
{ "clR6x12-iso-8859-1.bdf", FontManager::kGUIFont },
|
|
|
|
{ "clR6x12-ascii.bdf", FontManager::kGUIFont },
|
|
|
|
{ "helvB12.bdf", FontManager::kBigGUIFont },
|
|
|
|
{ "helvB12-iso-8859-1.bdf", FontManager::kBigGUIFont },
|
|
|
|
{ "helvB12-ascii.bdf", FontManager::kBigGUIFont },
|
2011-05-22 14:15:15 +00:00
|
|
|
{ 0, FontManager::kConsoleFont }
|
2010-06-15 10:51:26 +00:00
|
|
|
};
|
|
|
|
|
2006-04-14 02:16:55 +00:00
|
|
|
const Font *FontManager::getFontByName(const Common::String &name) const {
|
2010-06-28 15:17:10 +00:00
|
|
|
for (int i = 0; builtinFontNames[i].name; i++)
|
|
|
|
if (!scumm_stricmp(name.c_str(), builtinFontNames[i].name))
|
|
|
|
return getFontByUsage(builtinFontNames[i].id);
|
2010-06-15 10:51:26 +00:00
|
|
|
|
2006-04-14 02:16:55 +00:00
|
|
|
if (!_fontMap.contains(name))
|
|
|
|
return 0;
|
|
|
|
return _fontMap[name];
|
|
|
|
}
|
2005-01-06 21:15:52 +00:00
|
|
|
|
|
|
|
const Font *FontManager::getFontByUsage(FontUsage usage) const {
|
|
|
|
switch (usage) {
|
2005-10-08 21:11:45 +00:00
|
|
|
case kConsoleFont:
|
|
|
|
return g_consolefont;
|
|
|
|
case kGUIFont:
|
|
|
|
return g_sysfont;
|
|
|
|
case kBigGUIFont:
|
|
|
|
return g_sysfont_big;
|
2005-01-06 21:15:52 +00:00
|
|
|
}
|
2005-10-08 21:11:45 +00:00
|
|
|
|
2005-01-06 21:15:52 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Graphics
|