GG
Friends

GG::FontManager Class Reference

A singleton that loads and stores fonts for use by GG. More...

#include <Font.h>

List of all members.

Friends

GG_API FontManagerGetFontManager ()

Mutators

boost::shared_ptr< FontGetFont (const std::string &font_filename, unsigned int pts)
boost::shared_ptr< FontGetFont (const std::string &font_filename, unsigned int pts, const std::vector< unsigned char > &file_contents)
template<class CharSetIter >
boost::shared_ptr< FontGetFont (const std::string &font_filename, unsigned int pts, CharSetIter first, CharSetIter last)
template<class CharSetIter >
boost::shared_ptr< FontGetFont (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)

Detailed Description

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.

Definition at line 626 of file Font.h.


Member Function Documentation

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.

Note:
May load font if unavailable at time of request.

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.

Note:
May load font if unavailable at time of request.
template<class CharSetIter >
boost::shared_ptr< GG::Font > GG::FontManager::GetFont ( const std::string &  font_filename,
unsigned int  pts,
CharSetIter  first,
CharSetIter  last 
)

Returns a shared_ptr to the requested font, supporting all the code points in the UnicodeCharsets in the range [first, last).

Note:
May load font if unavailable at time of request.

Definition at line 851 of file Font.h.

template<class CharSetIter >
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 
)

Returns a shared_ptr to the requested font, supporting all the code points in the UnicodeCharsets in the range [first, last), from the in-memory contents file_contents.

Note:
May load font if unavailable at time of request.

Definition at line 857 of file Font.h.

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.


Friends And Related Function Documentation

GG_API FontManager& GetFontManager ( ) [friend]

Returns the singleton FontManager instance.


The documentation for this class was generated from the following file: