Hasty Badger
Small UI library (a branch of Turbo Badger)
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends Groups Pages
tb::TBFontManager Class Reference

TBFontManager creates and owns font faces (TBFontFace) which are looked up from TBFontDescription using GetFontFace. More...

#include <tb_font_renderer.h>

Public Member Functions

void AddRenderer (TBFontRenderer *renderer)
 Add a renderer so fonts supported by the renderer can be created. More...
 
void RemoveRenderer (TBFontRenderer *renderer)
 
TBFontInfoAddFontInfo (const char *filename, const char *name)
 Add TBFontInfo for the given font filename, so it can be loaded and identified using the font id in a TBFontDescription. More...
 
TBFontInfoGetFontInfo (const TBID &id) const
 Get TBFontInfo for the given font id, or nullptr if there is no match. More...
 
bool HasFontFace (const TBFontDescription &font_desc) const
 Return true if there is a font loaded that match the given font description. More...
 
TBFontFaceGetFontFace (const TBFontDescription &font_desc)
 Get a loaded font matching the description, or the default font if there is no exact match. More...
 
TBFontFaceCreateFontFace (const TBFontDescription &font_desc)
 Create and add a font with the given description. More...
 
void SetDefaultFontDescription (const TBFontDescription &font_desc)
 Set the default font description. More...
 
TBFontDescription GetDefaultFontDescription () const
 
TBFontGlyphCacheGetGlyphCache ()
 Return the glyph cache used for fonts created by this font manager. More...
 

Detailed Description

TBFontManager creates and owns font faces (TBFontFace) which are looked up from TBFontDescription using GetFontFace.

The fonts it can return must first have their file added and indexed (AddFontInfo), and then created CreateFontFace. Otherwise when asking for a font and it doesn't exist, it will use the default font.

Font ID 0 is always populated with a dummy font that draws squares. This font is generally not used for other things than unit testing or as fallback when there is no font backend implemented yet. Since there is always at least the test font, no nullptr checks are needed.

Member Function Documentation

TBFontInfo * tb::TBFontManager::AddFontInfo ( const char *  filename,
const char *  name 
)

Add TBFontInfo for the given font filename, so it can be loaded and identified using the font id in a TBFontDescription.

void tb::TBFontManager::AddRenderer ( TBFontRenderer renderer)
inline

Add a renderer so fonts supported by the renderer can be created.

Ownership of the renderer is taken, until calling RemoveRenderer.

TBFontFace * tb::TBFontManager::CreateFontFace ( const TBFontDescription font_desc)

Create and add a font with the given description.

Returns the created font face, or nullptr on fail. The font is owned by this TBFontManager, and can be recieved from GetFontFace using the same TBFontDescription.

TBFontFace * tb::TBFontManager::GetFontFace ( const TBFontDescription font_desc)

Get a loaded font matching the description, or the default font if there is no exact match.

If there is not even any default font loaded, it will return the test dummy font (rendering only squares).

TBFontInfo * tb::TBFontManager::GetFontInfo ( const TBID id) const

Get TBFontInfo for the given font id, or nullptr if there is no match.

TBFontGlyphCache* tb::TBFontManager::GetGlyphCache ( )
inline

Return the glyph cache used for fonts created by this font manager.

bool tb::TBFontManager::HasFontFace ( const TBFontDescription font_desc) const

Return true if there is a font loaded that match the given font description.

void tb::TBFontManager::SetDefaultFontDescription ( const TBFontDescription font_desc)
inline

Set the default font description.

This is the font description that will be used by default for widgets. By default, the default description is using the test dummy font.


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