mirror of
https://github.com/RGBCube/serenity
synced 2025-07-22 21:57:35 +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
|
int Font::width(const String& string) const
|
||||||
{
|
{
|
||||||
|
if (string.is_empty())
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (m_fixed_width)
|
if (m_fixed_width)
|
||||||
return string.length() * m_glyph_width;
|
return string.length() * m_glyph_width;
|
||||||
|
|
||||||
int width = 0;
|
int width = 0;
|
||||||
for (int i = 0; i < string.length(); ++i)
|
for (int i = 0; i < string.length(); ++i)
|
||||||
width += glyph_width(string[i]) + 1;
|
width += glyph_width(string[i]) + 1;
|
||||||
return width;
|
|
||||||
|
return width - 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue