19#ifndef HEADER_FONT_MANAGER_HPP
20#define HEADER_FONT_MANAGER_HPP
26#include "utils/leak_check.hpp"
27#include "utils/log.hpp"
28#include "utils/no_copy.hpp"
33#include <unordered_map>
38#include <harfbuzz/hb.h>
42#include "GlyphLayout.h"
75 std::map<irr::core::stringw,
78 bool m_has_color_emoji;
80 std::vector<FT_Face>
loadTTF(
const std::vector<std::string>& ttf_list);
82 hb_buffer_t* m_hb_buffer;
84 std::vector<hb_font_t*> m_hb_fonts;
102 out =
dynamic_cast<T*
>(
m_fonts[n]);
107 Log::fatal(
"FontManager",
"Can't get a font!");
120 Log::error(
"FontManager",
"Something wrong when %s! The error "
121 "code was %d.", desc.c_str(), err);
125 bool hasColorEmoji()
const {
return m_has_color_emoji; }
130 FT_Face loadColorEmoji();
134 void shape(
const std::u32string& text,
135 std::vector<irr::gui::GlyphLayout>& gls,
136 irr::u32 shape_flag = 0);
138 std::vector<irr::gui::GlyphLayout>& getCachedLayouts
139 (
const irr::core::stringw& str);
144 std::vector<irr::gui::GlyphLayout>& gls,
145 irr::u32 shape_flag = 0);
This class stores all font files required in STK.
Definition: font_manager.hpp:51
T * getFont()
Return a specfic type of FontWithFace found in m_fonts.
Definition: font_manager.hpp:98
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,...
Definition: font_manager.hpp:116
std::vector< FontWithFace * > m_fonts
Stores all FontWithFace used in STK.
Definition: font_manager.hpp:54
std::map< irr::core::stringw, std::vector< irr::gui::GlyphLayout > > m_cached_gls
Text drawn to glyph layouts cache.
Definition: font_manager.hpp:76
void unitTesting()
Unit testing that will try to load all translations in STK, and discover if there is any characters r...
Definition: font_manager.cpp:870
unsigned m_shaping_dpi
DPI used when shaping, each face will apply an inverse of this and the dpi of itself when rendering,...
Definition: font_manager.hpp:69
FT_Library m_ft_library
A FreeType library, it holds the FT_Face internally inside freetype.
Definition: font_manager.hpp:58
FT_Face m_digit_face
TTF file for digit font in STK.
Definition: font_manager.hpp:64
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.
Definition: font_manager.cpp:688
std::map< FT_Face, uint16_t > m_ft_faces_to_index
Map FT_Face to index for quicker layout.
Definition: font_manager.hpp:72
FT_Library getFTLibrary() const
Return the m_ft_library.
Definition: font_manager.hpp:128
void loadFonts()
Initialize all FaceTTF and FontWithFace members.
Definition: font_manager.cpp:780
std::vector< FT_Face > m_faces
List of TTF files for complex text shaping.
Definition: font_manager.hpp:61
std::vector< FT_Face > loadTTF(const std::vector< std::string > &ttf_list)
Load all TTFs from a list to m_faces.
Definition: font_manager.cpp:90
std::unordered_map< std::type_index, int > m_font_type_map
Map type for each FontWithFace with a index, save getting time in getFont.
Definition: font_manager.hpp:89
An abstract class which contains functions which convert vector fonts into bitmap and render them in ...
Definition: font_with_face.hpp:72
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26