1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-10-08 23:41:06 +00:00

Add Lua function text_getStringWidth()

This commit is contained in:
fgenesis 2015-03-08 20:43:41 +01:00
commit b70de7f94b
6 changed files with 53 additions and 1 deletions

View file

@ -52,6 +52,24 @@ float DebugFont::getHeight()
return fontDrawSize * lines.size() * 1.5f; // vspc in render()
}
float DebugFont::getStringWidth(const std::string& text)
{
int maxchars = 0;
int c = 0;
for (size_t i = 0; i < text.size(); i++)
{
if(text[i] == '\n')
{
maxchars = std::max(maxchars, c);
c = 0;
}
else
++c;
}
maxchars = std::max(maxchars, c);
return float(fontDrawSize * maxchars);
}
void DebugFont::formatText()
{
std::string text;