Avoid rendering artifacts when label text is shaped with a non-integer width

Max Brunsfeld and Nathan Sobo created

Co-Authored-By: Nathan Sobo <nathan@zed.dev>

Change summary

gpui/src/elements/label.rs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

Detailed changes

gpui/src/elements/label.rs 🔗

@@ -135,7 +135,10 @@ impl Element for Label {
         );
 
         let size = vec2f(
-            line.width().max(constraint.min.x()).min(constraint.max.x()),
+            line.width()
+                .ceil()
+                .max(constraint.min.x())
+                .min(constraint.max.x()),
             cx.font_cache
                 .line_height(self.style.text.font_id, self.style.text.font_size),
         );