GG: GG::FontManager Class Reference

GG

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Friends | List of all members
GG::FontManager Class Reference

`#include <Font.h>`

## Friends
GG_API FontManager & | GetFontManager ()

## Accessors
bool | HasFont (const std::string &font_filename, unsigned int pts) const
template<class CharSetIter >
bool | HasFont (const std::string &font_filename, unsigned int pts, CharSetIter first, CharSetIter last) const

## 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)

## 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 598 of file Font.h.

## Member Function Documentation

bool GG::FontManager::HasFont | ( | const std::string & | font_filename,
|  | unsigned int | pts
| ) |  | const

Returns true iff this manager contains a font with the given filename and point size, regardless of charsets.

template<class CharSetIter >

bool GG::FontManager::HasFont | ( | const std::string & | font_filename,
|  | unsigned int | pts,
|  | CharSetIter | first,
|  | CharSetIter | last
| ) |  | const

Returns true iff this manager contains a font with the given filename and point size, containing the given charsets.

Definition at line 755 of file Font.h.

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 772 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 778 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:

- Font.h