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.
|
2014-02-18 01:34:20 +00:00
|
|
|
*
|
2005-01-06 21:15:52 +00:00
|
|
|
*/
|
|
|
|
|
2006-04-15 21:29:41 +00:00
|
|
|
#ifndef GRAPHICS_FONTMAN_H
|
|
|
|
#define GRAPHICS_FONTMAN_H
|
2005-01-06 21:15:52 +00:00
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/singleton.h"
|
|
|
|
#include "common/str.h"
|
2006-04-14 02:16:55 +00:00
|
|
|
#include "common/hashmap.h"
|
2006-07-30 12:21:54 +00:00
|
|
|
#include "common/hash-str.h"
|
2005-01-06 21:15:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace Graphics {
|
|
|
|
|
2011-04-24 08:34:27 +00:00
|
|
|
class Font;
|
2012-01-07 00:16:33 +00:00
|
|
|
class BdfFont;
|
2011-04-24 08:34:27 +00:00
|
|
|
|
2005-01-06 21:15:52 +00:00
|
|
|
class FontManager : public Common::Singleton<FontManager> {
|
|
|
|
public:
|
|
|
|
enum FontUsage {
|
2011-05-22 20:55:28 +00:00
|
|
|
kLocalizedFont = 0,
|
2010-06-15 10:51:26 +00:00
|
|
|
kConsoleFont = 1,
|
|
|
|
kGUIFont = 2,
|
|
|
|
kBigGUIFont = 3
|
2005-01-06 21:15:52 +00:00
|
|
|
};
|
|
|
|
|
2012-01-07 00:00:31 +00:00
|
|
|
/**
|
|
|
|
* Sets the localized font name.
|
|
|
|
*
|
|
|
|
* @param name the name of the localized font.
|
|
|
|
* @return true when the font was present, false otherwise.
|
|
|
|
*/
|
|
|
|
bool setLocalizedFont(const Common::String &name);
|
|
|
|
|
2005-01-06 21:15:52 +00:00
|
|
|
/**
|
|
|
|
* Retrieve a font object based on its 'name'.
|
|
|
|
*
|
|
|
|
* @param name the name of the font to be retrieved.
|
|
|
|
* @return a pointer to a font, or 0 if no suitable font was found.
|
|
|
|
*/
|
2006-04-14 02:16:55 +00:00
|
|
|
const Font *getFontByName(const Common::String &name) const;
|
|
|
|
|
|
|
|
/**
|
2012-03-28 17:17:13 +00:00
|
|
|
* Associates a font object with an 'name'.
|
|
|
|
* The FontManager takes ownership of the provided font object
|
|
|
|
* and will delete it when necesssary.
|
2006-04-14 02:16:55 +00:00
|
|
|
*
|
|
|
|
* @param name the name of the font
|
|
|
|
* @param font the font object
|
|
|
|
* @return true on success, false on failure
|
|
|
|
*/
|
2011-05-22 20:55:28 +00:00
|
|
|
bool assignFontToName(const Common::String &name, const Font *font);
|
2006-04-14 02:16:55 +00:00
|
|
|
|
2011-08-07 11:33:32 +00:00
|
|
|
/**
|
|
|
|
* Associates a BDF font object with an 'usage'. This is useful for platforms
|
2011-08-22 07:53:06 +00:00
|
|
|
* with a screen DPI much larger than a regular desktop workstation.
|
2011-08-07 11:33:32 +00:00
|
|
|
*
|
|
|
|
* @param font the font object
|
|
|
|
* @return true on success, false on failure
|
|
|
|
*/
|
2012-01-07 00:16:33 +00:00
|
|
|
bool setFont(FontUsage usage, const BdfFont *font);
|
2011-08-07 11:33:32 +00:00
|
|
|
|
2006-04-14 02:16:55 +00:00
|
|
|
/**
|
|
|
|
* Removes binding from name to font
|
|
|
|
*
|
|
|
|
* @param name name which should be removed
|
|
|
|
*/
|
2011-05-22 20:55:28 +00:00
|
|
|
void removeFontName(const Common::String &name);
|
2005-01-06 21:15:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve a font object based on what it is supposed
|
|
|
|
* to be used for
|
|
|
|
*
|
|
|
|
* @param usage a FontUsage enum value indicating what the font will be used for.
|
|
|
|
* @return a pointer to a font, or 0 if no suitable font was found.
|
|
|
|
*/
|
|
|
|
const Font *getFontByUsage(FontUsage usage) const;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2011-05-22 14:43:35 +00:00
|
|
|
/**
|
|
|
|
* Get the localized font for the current TranslationManager charset from the
|
|
|
|
* non localized font name
|
|
|
|
*
|
|
|
|
* @param filename the non-localized font file name.
|
|
|
|
* @return The localized font file name.
|
|
|
|
*/
|
|
|
|
Common::String genLocalizedFontFilename(const Common::String &filename) const;
|
|
|
|
|
2005-01-06 21:15:52 +00:00
|
|
|
//const Font *getFontBySize(int size???) const;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-01-06 21:15:52 +00:00
|
|
|
private:
|
|
|
|
friend class Common::Singleton<SingletonBaseType>;
|
|
|
|
FontManager();
|
2009-12-09 16:44:48 +00:00
|
|
|
~FontManager();
|
2006-04-14 02:16:55 +00:00
|
|
|
|
2008-06-11 06:00:56 +00:00
|
|
|
Common::HashMap<Common::String, const Font *> _fontMap;
|
2012-03-28 17:17:13 +00:00
|
|
|
Common::Array<const Font *> _ownedFonts;
|
2012-01-07 00:00:31 +00:00
|
|
|
Common::String _localizedFontName;
|
2005-01-06 21:15:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // End of namespace Graphics
|
|
|
|
|
|
|
|
/** Shortcut for accessing the font manager. */
|
|
|
|
#define FontMan (Graphics::FontManager::instance())
|
|
|
|
|
|
|
|
#endif
|