19 #ifndef HEADER_FACE_TTF_HPP 20 #define HEADER_FACE_TTF_HPP 22 #include "utils/no_copy.hpp" 32 #include FT_FREETYPE_H 62 std::vector<std::pair<FT_Face, std::map<unsigned, FontArea> > >
m_ft_faces;
74 for (
unsigned int i = 0; i < m_ft_faces.size(); i++)
75 m_ft_faces[i].second.clear();
80 void loadTTF(std::vector<FT_Face> faces)
82 for (
unsigned int i = 0; i < faces.size(); i++)
83 m_ft_faces.emplace_back(faces[i], std::map<unsigned, FontArea>());
91 assert(i < m_ft_faces.size());
92 return m_ft_faces[i].first;
97 {
return (
unsigned int)m_ft_faces.size(); }
99 void insertFontArea(
const FontArea& a,
unsigned font_index,
100 unsigned glyph_index)
102 auto& ttf = m_ft_faces.at(font_index).second;
103 ttf[glyph_index] = a;
106 bool enabledForFont(
unsigned idx)
const 107 {
return m_ft_faces.size() > idx && m_ft_faces[idx].first != NULL; }
109 const FontArea* getFontArea(
unsigned font_index,
unsigned glyph_index)
111 auto& ttf = m_ft_faces.at(font_index).second;
112 auto it = ttf.find(glyph_index);
118 bool getFontAndGlyphFromChar(uint32_t c,
unsigned* font,
unsigned* glyph)
120 for (
unsigned i = 0; i < m_ft_faces.size(); i++)
122 unsigned glyph_index = FT_Get_Char_Index(m_ft_faces[i].first, c);
126 *glyph = glyph_index;
int offset_y_bt
Top side bearing for horizontal layout used in billboard text.
Definition: face_ttf.hpp:47
This class will load a list of TTF files from FontManager, and save them inside m_ft_faces for FontWi...
Definition: face_ttf.hpp:56
FT_Face getFace(unsigned int i) const
Return a TTF in m_ft_faces.
Definition: face_ttf.hpp:89
int advance_x
Advance width for horizontal layout.
Definition: face_ttf.hpp:41
int offset_y
Top side bearing for horizontal layout.
Definition: face_ttf.hpp:45
std::vector< std::pair< FT_Face, std::map< unsigned, FontArea > > > m_ft_faces
Contains all FT_Face with a list of loaded glyph index with the FontArea.
Definition: face_ttf.hpp:62
Glyph metrics for each glyph loaded.
Definition: face_ttf.hpp:36
int bearing_x
Left side bearing for horizontal layout.
Definition: face_ttf.hpp:43
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:25
int spriteno
Index number in sprite bank of FontWithFace.
Definition: face_ttf.hpp:49
unsigned int getTotalFaces() const
Return the total TTF files loaded.
Definition: face_ttf.hpp:96