summaryrefslogtreecommitdiff
path: root/SharedGraphics/Font.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-25 13:35:24 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-25 13:35:24 +0100
commit08085f48a098ab79f36321471759b05c455ff49a (patch)
tree6816a8ce775574cdba21e7b3d487dda6c05a3a87 /SharedGraphics/Font.cpp
parent838a06096ac2522f9f5b6a2fb8a8096290520db5 (diff)
downloadserenity-08085f48a098ab79f36321471759b05c455ff49a.zip
SharedGraphics: Font::width() shouldn't add spacing to the very last glyph.
Diffstat (limited to 'SharedGraphics/Font.cpp')
-rw-r--r--SharedGraphics/Font.cpp6
1 files changed, 5 insertions, 1 deletions
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;
}