Add Font:getAscent/getDescent/getBaseline (issue #445)

This commit is contained in:
Bart van Strien
2013-01-18 13:20:40 +01:00
parent 84b6eedf1f
commit 32684b674e
4 changed files with 49 additions and 2 deletions
+17 -2
View File
@@ -291,8 +291,7 @@ void Font::print(const std::string &text, float x, float y, float letter_spacing
// copy glyphquad (4 vertices) from original glyph to our current quad list
glyphquads.push_back(glyph->quad);
// 1.25 is magic line height for true type fonts
float lineheight = (type == FONT_TRUETYPE) ? floor(getHeight() / 1.25f + 0.5f) : 0.0f;
float lineheight = getBaseline();
// set proper relative position
for (int i = 0; i < 4; i++)
@@ -592,6 +591,22 @@ void Font::unloadVolatile()
textures.clear();
}
int Font::getAscent() const
{
return rasterizer->getAscent();
}
int Font::getDescent() const
{
return rasterizer->getDescent();
}
float Font::getBaseline() const
{
// 1.25 is magic line height for true type fonts
return (type == FONT_TRUETYPE) ? floor(getHeight() / 1.25f + 0.5f) : 0.0f;
}
} // opengl
} // graphics
} // love