From 08085f48a098ab79f36321471759b05c455ff49a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 25 Mar 2019 13:35:24 +0100 Subject: [PATCH] SharedGraphics: Font::width() shouldn't add spacing to the very last glyph. --- SharedGraphics/Font.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SharedGraphics/Font.cpp b/SharedGraphics/Font.cpp index c79db453ed..a6bbb4cc27 100644 --- a/SharedGraphics/Font.cpp +++ b/SharedGraphics/Font.cpp @@ -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; }