SuperTuxKart
Public Member Functions | Private Member Functions | Private Attributes | List of all members
FontManager Class Reference

This class stores all font files required in STK. More...

#include <font_manager.hpp>

Inheritance diagram for FontManager:
Inheritance graph
[legend]

Public Member Functions

 FontManager ()
 Constructor. More...
 
 ~FontManager ()
 Destructor. More...
 
template<typename T >
T * getFont ()
 Return a specfic type of FontWithFace found in m_fonts. More...
 
void checkFTError (FT_Error err, const std::string &desc) const
 Check for any error discovered in a freetype function that will return a FT_Error value, and log into the terminal. More...
 
bool hasColorEmoji () const
 
FT_Library getFTLibrary () const
 Return the m_ft_library. More...
 
FT_Face loadColorEmoji ()
 
unsigned getShapingDPI () const
 
void shape (const std::u32string &text, std::vector< irr::gui::GlyphLayout > &gls, std::vector< std::u32string > *line_data=NULL)
 
std::vector< irr::gui::GlyphLayout > & getCachedLayouts (const irr::core::stringw &str)
 
void clearCachedLayouts ()
 
void initGlyphLayouts (const irr::core::stringw &text, std::vector< irr::gui::GlyphLayout > &gls, std::vector< std::u32string > *line_data=NULL)
 Convert text to glyph layouts for fast rendering with caching enabled If line_data is not null, each broken line u32string will be saved and can be used for advanced glyph and text mapping, and cache will be disabled, no newline characters are allowed in text if line_data is not NULL.
 
void loadFonts ()
 Initialize all FaceTTF and FontWithFace members.
 
void unitTesting ()
 Unit testing that will try to load all translations in STK, and discover if there is any characters required by it are not supported in m_normal_ttf.
 

Private Member Functions

std::vector< FT_Face > loadTTF (const std::vector< std::string > &ttf_list)
 Load all TTFs from a list to m_faces. More...
 

Private Attributes

std::vector< FontWithFace * > m_fonts
 Stores all FontWithFace used in STK. More...
 
FT_Library m_ft_library
 A FreeType library, it holds the FT_Face internally inside freetype. More...
 
std::vector< FT_Face > m_faces
 List of TTF files for complex text shaping. More...
 
FT_Face m_digit_face
 TTF file for digit font in STK. More...
 
unsigned m_shaping_dpi
 DPI used when shaping, each face will apply an inverse of this and the dpi of itself when rendering, so all faces can share the same glyph layout cache. More...
 
std::map< FT_Face, uint16_t > m_ft_faces_to_index
 Map FT_Face to index for quicker layout. More...
 
std::map< irr::core::stringw, std::vector< irr::gui::GlyphLayout > > m_cached_gls
 Text drawn to glyph layouts cache. More...
 
bool m_has_color_emoji
 
std::unordered_map< std::type_index, int > m_font_type_map
 Map type for each FontWithFace with a index, save getting time in getFont. More...
 

Detailed Description

This class stores all font files required in STK.

Constructor & Destructor Documentation

◆ FontManager()

FontManager::FontManager ( )

Constructor.

It will initialize the m_ft_library.

◆ ~FontManager()

FontManager::~FontManager ( )

Destructor.

Clears all fonts and related stuff.

Member Function Documentation

◆ checkFTError()

void FontManager::checkFTError ( FT_Error  err,
const std::string &  desc 
) const
inline

Check for any error discovered in a freetype function that will return a FT_Error value, and log into the terminal.

Parameters
errThe Freetype function.
descThe description of what is the function doing.

◆ getFont()

template<typename T >
T* FontManager::getFont ( )
inline

Return a specfic type of FontWithFace found in m_fonts.

◆ getFTLibrary()

FT_Library FontManager::getFTLibrary ( ) const
inline

Return the m_ft_library.

◆ loadTTF()

std::vector< FT_Face > FontManager::loadTTF ( const std::vector< std::string > &  ttf_list)
private

Load all TTFs from a list to m_faces.

Parameters
ttf_listList of TTFs to be loaded.

Member Data Documentation

◆ m_cached_gls

std::map<irr::core::stringw, std::vector<irr::gui::GlyphLayout> > FontManager::m_cached_gls
private

Text drawn to glyph layouts cache.

◆ m_digit_face

FT_Face FontManager::m_digit_face
private

TTF file for digit font in STK.

◆ m_faces

std::vector<FT_Face> FontManager::m_faces
private

List of TTF files for complex text shaping.

◆ m_font_type_map

std::unordered_map<std::type_index, int> FontManager::m_font_type_map
private

Map type for each FontWithFace with a index, save getting time in getFont.

◆ m_fonts

std::vector<FontWithFace*> FontManager::m_fonts
private

Stores all FontWithFace used in STK.

◆ m_ft_faces_to_index

std::map<FT_Face, uint16_t> FontManager::m_ft_faces_to_index
private

Map FT_Face to index for quicker layout.

◆ m_ft_library

FT_Library FontManager::m_ft_library
private

A FreeType library, it holds the FT_Face internally inside freetype.

◆ m_shaping_dpi

unsigned FontManager::m_shaping_dpi
private

DPI used when shaping, each face will apply an inverse of this and the dpi of itself when rendering, so all faces can share the same glyph layout cache.


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