浏览代码

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.
Andreas Kling 3 年之前
父节点
当前提交
44025e837f
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      Userland/Libraries/LibGfx/Font/ScaledFont.cpp

+ 2 - 2
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') {