diff --git a/src/Font.cc b/src/Font.cc index 0ad0a03..80e124b 100644 --- a/src/Font.cc +++ b/src/Font.cc @@ -55,14 +55,13 @@ bool Font::preload_glyphs() { return false; } - if (m_face->glyph->bitmap_top > max_top) + if (g->get_top() > max_top) { - max_top = m_face->glyph->bitmap_top; + max_top = g->get_top(); } - int bitmap_bottom = m_face->glyph->bitmap_top - m_face->glyph->bitmap.rows; - if (bitmap_bottom < min_bottom) + if (g->get_bottom() < min_bottom) { - min_bottom = bitmap_bottom; + min_bottom = g->get_bottom(); } if (g->get_advance() > m_advance) { diff --git a/src/Glyph.cc b/src/Glyph.cc index 1dfb445..ee72c39 100644 --- a/src/Glyph.cc +++ b/src/Glyph.cc @@ -62,6 +62,9 @@ bool Glyph::load(FT_Library library, FT_Face face, FT_ULong char_code, int outli (GLfloat)(left + width), (GLfloat)top, s_max, t_max, }); + m_top = top; + m_bottom = top - height; + glEnableVertexAttribArray(0); glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0); diff --git a/src/Glyph.h b/src/Glyph.h index 8046678..ced2ead 100644 --- a/src/Glyph.h +++ b/src/Glyph.h @@ -16,9 +16,13 @@ public: m_texture->bind(GL_TEXTURE_2D); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } + int get_top() { return m_top; } + int get_bottom() { return m_bottom; } protected: int m_advance; + int m_top; + int m_bottom; std::shared_ptr m_texture; std::shared_ptr m_buffer; std::shared_ptr m_array;