diff options
author | Andreas Kling <kling@serenityos.org> | 2022-07-08 21:03:23 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-07-09 22:16:18 +0200 |
commit | 44025e837fef1af6fe6ac567d7705dbc9f049375 (patch) | |
tree | a165b4197f97805aec3a10b157f31c2c999e11db /Userland | |
parent | 80ed7d220c3df9ccc9678dda5266f8a4a776a4f1 (diff) | |
download | serenity-44025e837fef1af6fe6ac567d7705dbc9f049375.zip |
LibGfx: Use float when calculating text width in ScaledFont
This fixes an issue where we'd truncate the fractional part of each
glyph width, often making the returned width slightly too short.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGfx/Font/ScaledFont.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibGfx/Font/ScaledFont.cpp b/Userland/Libraries/LibGfx/Font/ScaledFont.cpp index 8f5e9dc889..8dd9b84f08 100644 --- a/Userland/Libraries/LibGfx/Font/ScaledFont.cpp +++ b/Userland/Libraries/LibGfx/Font/ScaledFont.cpp @@ -19,8 +19,8 @@ ALWAYS_INLINE int ScaledFont::unicode_view_width(T const& view) const { if (view.is_empty()) return 0; - int width = 0; - int longest_width = 0; + float width = 0; + float longest_width = 0; u32 last_code_point = 0; for (auto code_point : view) { if (code_point == '\n' || code_point == '\r') { |