mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:38:11 +00:00
SharedGraphics: Font::width() shouldn't add spacing to the very last glyph.
This commit is contained in:
parent
838a06096a
commit
08085f48a0
1 changed files with 5 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue