Skip to content

Commit 08085f4

Browse files
committed
SharedGraphics: Font::width() shouldn't add spacing to the very last glyph.
1 parent 838a060 commit 08085f4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

SharedGraphics/Font.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,15 @@ bool Font::write_to_file(const String& path)
177177

178178
int Font::width(const String& string) const
179179
{
180+
if (string.is_empty())
181+
return 0;
182+
180183
if (m_fixed_width)
181184
return string.length() * m_glyph_width;
182185

183186
int width = 0;
184187
for (int i = 0; i < string.length(); ++i)
185188
width += glyph_width(string[i]) + 1;
186-
return width;
189+
190+
return width - 1;
187191
}

0 commit comments

Comments
 (0)