SharedGraphics: Font::width() shouldn't add spacing to the very last glyph.

This commit is contained in:
Andreas Kling 2019-03-25 13:35:24 +01:00
parent 838a06096a
commit 08085f48a0
Notes: sideshowbarker 2024-07-19 14:56:43 +09:00

View File

@ -177,11 +177,15 @@ bool Font::write_to_file(const String& path)
int Font::width(const String& string) const
{
if (string.is_empty())
return 0;
if (m_fixed_width)
return string.length() * m_glyph_width;
int width = 0;
for (int i = 0; i < string.length(); ++i)
width += glyph_width(string[i]) + 1;
return width;
return width - 1;
}