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:
parent
dee156cf7a
commit
b70de7f94b
6 changed files with 53 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue