summaryrefslogtreecommitdiff
path: root/SharedGraphics/Font.cpp
diff options
context:
space:
mode:
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;
}