mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Add Font:getAscent/getDescent/getBaseline (issue #445)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user