12 #ifndef GLVIS_FONT_HPP
13 #define GLVIS_FONT_HPP
16 #include FT_FREETYPE_H
42 glyph font_chars[256];
49 bool face_has_kerning;
52 bool LoadFont(
const std::string& path,
int font_index,
int font_size);
56 return font_chars[(uint8_t) c];
60 void getObjectSize(
const std::string& text,
int& w,
int& h);
65 face_has_kerning(false)
67 if (FT_Init_FreeType(&library))
69 cout <<
"GLVis: Can not initialize FreeType library!" << endl;
78 FT_Done_FreeType(library);
84 if (!face_has_kerning || cprev ==
'\0')
88 FT_UInt glyph_prev = FT_Get_Char_Index(face, cprev);
89 FT_UInt glyph_curr = FT_Get_Char_Index(face, c);
92 FT_Get_Kerning(face, glyph_prev, glyph_curr,
93 FT_KERNING_DEFAULT, &delta);
94 return delta.x / 64.f;
void setAlphaChannel(GLenum alpha)
float getFontLineSpacing() const
float getFontDescender() const
float GetKerning(char cprev, char c)
const glyph & GetTexChar(char c) const