SuperTuxKart
Loading...
Searching...
No Matches
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.
 
 ~FontManager ()
 Destructor.
 
template<typename T >
T * getFont ()
 Return a specfic type of FontWithFace found in m_fonts.
 
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.
 
bool hasColorEmoji () const
 
FT_Library getFTLibrary () const
 Return the m_ft_library.
 
FT_Face loadColorEmoji ()
 
unsigned getShapingDPI () const
 
void shape (const std::u32string &text, std::vector< irr::gui::GlyphLayout > &gls, irr::u32 shape_flag=0)
 
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, irr::u32 shape_flag=0)
 Convert text to glyph layouts for fast rendering with (optional) caching enabled.
 
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.
 

Private Attributes

std::vector< FontWithFace * > m_fonts
 Stores all FontWithFace used in STK.
 
FT_Library m_ft_library
 A FreeType library, it holds the FT_Face internally inside freetype.
 
std::vector< FT_Face > m_faces
 List of TTF files for complex text shaping.
 
FT_Face m_digit_face
 TTF file for digit font in STK.
 
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.
 
std::map< FT_Face, uint16_t > m_ft_faces_to_index
 Map FT_Face to index for quicker layout.
 
std::map< irr::core::stringw, std::vector< irr::gui::GlyphLayout > > m_cached_gls
 Text drawn to glyph layouts cache.
 
bool m_has_color_emoji
 
hb_buffer_t * m_hb_buffer
 
std::vector< hb_font_t * > m_hb_fonts
 
std::unordered_map< std::type_index, int > m_font_type_map
 Map type for each FontWithFace with a index, save getting time in getFont.
 

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.

◆ 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.

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