From 7daf10e3b540f612cbc48973469656ecd1635dfc Mon Sep 17 00:00:00 2001 From: Connor-GH Date: Wed, 29 Jul 2026 15:49:10 -0500 Subject: [PATCH] fix: round subpixel coordinates for glyph background rectangles `cosmic-term` currently has an issue where borders appear to separate some cells columnwise. This was caused due to the accumulation of floating point error when using font sizes that can't be fully represented in an f32. For example, a font size of 8.4x20 and a unique color per cell is enough to reproduce this. Essentially, the glyph background rectangles are being drawn slightly too narrow, causing the terminal background to leak through. This patch rounds the rectangles in such a way that we guarantee the drawing of that "border" pixel using floor() and ceil(). --- src/terminal_box.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/terminal_box.rs b/src/terminal_box.rs index 545997f..3abb5b3 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -557,7 +557,7 @@ where macro_rules! mk_pos_offset { ($x_offset:expr, $bottom_offset:expr) => { Vector::new( - self.start_x + $x_offset, + (self.start_x + $x_offset).floor(), self.line_top + self.line_height - $bottom_offset, ) }; @@ -574,7 +574,11 @@ where } }; ($pos_offset:expr, $style_line_height:expr) => { - mk_quad!($pos_offset, $style_line_height, self.end_x - self.start_x) + mk_quad!( + $pos_offset, + $style_line_height, + (self.end_x - self.start_x).ceil() + ) }; }