dEngine
Simple 2D C++ game engine
|
Font Manager. More...
#include <FontManager.h>
Public Member Functions | |
void | AddFont (std::string name, std::string filePath, int size) |
Add a font to the system. More... | |
void | RemoveFont (std::string name) |
Remove a font. More... | |
~FontManager () | |
Destructor. More... | |
SDL_Texture * | Text (std::string fontName, SDL_Color color, std::string text) |
Static Public Member Functions | |
static FontManager & | GetInstance () |
Returns an instance of the font manager. More... | |
Private Attributes | |
std::map< std::string, TTF_Font * > | fonts |
Static Private Attributes | |
static FontManager * | instance |
Font Manager.
A singleton manager that manages all TTF's in the game
FontManager::~FontManager | ( | ) |
Destructor.
Unloads and destroys all TTF_Fonts
void FontManager::AddFont | ( | std::string | name, |
std::string | filePath, | ||
int | size | ||
) |
Add a font to the system.
Reads a TTF from the filePath and generates a TTF_Font from SDL_TTF
name | The name of the font |
filePath | The filepath to the font |
size | The font size |
|
static |
Returns an instance of the font manager.
In order to ensure singleton pattern is maintained, this function is used to retrieve the instance of the FontManager
Referenced by dengine_UI::Text::Render().
void FontManager::RemoveFont | ( | std::string | name | ) |
Remove a font.
Destroys a TTF_Font and removes its references, release memory.
name | The name of the font |
SDL_Texture * FontManager::Text | ( | std::string | fontName, |
SDL_Color | color, | ||
std::string | text | ||
) |
Referenced by dengine_UI::Text::Render().
|
private |
|
staticprivate |