dEngine
Simple 2D C++ game engine
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
dengine_UI::FontManager Class Reference

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 FontManagerGetInstance ()
 Returns an instance of the font manager. More...
 

Private Attributes

std::map< std::string, TTF_Font * > fonts
 

Static Private Attributes

static FontManagerinstance
 

Detailed Description

Font Manager.

A singleton manager that manages all TTF's in the game

Constructor & Destructor Documentation

◆ ~FontManager()

FontManager::~FontManager ( )

Destructor.

Unloads and destroys all TTF_Fonts

Member Function Documentation

◆ AddFont()

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

Parameters
nameThe name of the font
filePathThe filepath to the font
sizeThe font size

◆ GetInstance()

FontManager & FontManager::GetInstance ( )
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

Returns

Referenced by dengine_UI::Text::Render().

◆ RemoveFont()

void FontManager::RemoveFont ( std::string  name)

Remove a font.

Destroys a TTF_Font and removes its references, release memory.

Parameters
nameThe name of the font

◆ Text()

SDL_Texture * FontManager::Text ( std::string  fontName,
SDL_Color  color,
std::string  text 
)

Member Data Documentation

◆ fonts

std::map<std::string,TTF_Font*> dengine_UI::FontManager::fonts
private

◆ instance

FontManager * FontManager::instance
staticprivate