GG
|
A singleton that loads and stores fonts for use by GG. More...
#include <Font.h>
Friends | |
GG_API FontManager & | GetFontManager () |
Mutators | |
boost::shared_ptr< Font > | GetFont (const std::string &font_filename, unsigned int pts) |
boost::shared_ptr< Font > | GetFont (const std::string &font_filename, unsigned int pts, const std::vector< unsigned char > &file_contents) |
template<class CharSetIter > | |
boost::shared_ptr< Font > | GetFont (const std::string &font_filename, unsigned int pts, CharSetIter first, CharSetIter last) |
template<class CharSetIter > | |
boost::shared_ptr< Font > | GetFont (const std::string &font_filename, unsigned int pts, const std::vector< unsigned char > &file_contents, CharSetIter first, CharSetIter last) |
void | FreeFont (const std::string &font_filename, unsigned int pts) |
A singleton that loads and stores fonts for use by GG.
This class is essentially a very thin wrapper around a map of Font smart pointers, keyed on font filename/point size pairs. The user need only request a font through GetFont(); if the font at the requested size needs to be created, the font is created at the requestd size, a shared_ptr to it is kept, and a copy of the shared_ptr is returned. If the font has been created at the desired size, but the request includes code point range(s) not already created, the font at the requested size is created with the union of the reqested and existing ranges, stored, and returned as above; the only difference is that the original shared_ptr is released. Due to the shared_ptr semantics, the object pointed to by the shared_ptr is deleted if and only if the last shared_ptr that refers to it is deleted. So any requested font can be used as long as the caller desires, even when another caller tells the FontManager to free the font.
boost::shared_ptr<Font> GG::FontManager::GetFont | ( | const std::string & | font_filename, |
unsigned int | pts | ||
) |
Returns a shared_ptr to the requested font, supporting all printable ASCII characters.
Referenced by GG::GUI::GetFont().
boost::shared_ptr<Font> GG::FontManager::GetFont | ( | const std::string & | font_filename, |
unsigned int | pts, | ||
const std::vector< unsigned char > & | file_contents | ||
) |
Returns a shared_ptr to the requested font, supporting all printable ASCII characters, from the in-memory contents file_contents.
boost::shared_ptr< GG::Font > GG::FontManager::GetFont | ( | const std::string & | font_filename, |
unsigned int | pts, | ||
CharSetIter | first, | ||
CharSetIter | last | ||
) |
boost::shared_ptr< GG::Font > GG::FontManager::GetFont | ( | const std::string & | font_filename, |
unsigned int | pts, | ||
const std::vector< unsigned char > & | file_contents, | ||
CharSetIter | first, | ||
CharSetIter | last | ||
) |
void GG::FontManager::FreeFont | ( | const std::string & | font_filename, |
unsigned int | pts | ||
) |
Removes the indicated font from the font manager. Due to shared_ptr semantics, the font may not be deleted until much later.
GG_API FontManager& GetFontManager | ( | ) | [friend] |
Returns the singleton FontManager instance.