From 3b1aa511d19aaa40be447a9b7ebe212b1bbb6a9a Mon Sep 17 00:00:00 2001 From: Erik McClure <3387013+ErikMcClure@users.noreply.github.com> Date: Sat, 28 Jun 2025 12:03:47 -0700 Subject: [PATCH] Clip based on ascent and descent, not baseline (#396) Due to https://github.com/pop-os/cosmic-text/pull/141 the LayoutRunIter incorrect checks to see if the baseline is past the visible bounds of the buffer, instead of using the maximum ascent and maximum descent from the baseline. --- src/buffer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/buffer.rs b/src/buffer.rs index 0292e6b..ba234f2 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -131,12 +131,12 @@ impl<'b> Iterator for LayoutRunIter<'b> { let centering_offset = (line_height - glyph_height) / 2.0; let line_y = line_top + centering_offset + layout_line.max_ascent; if let Some(height) = self.buffer.height_opt { - if line_y > height { + if line_y - layout_line.max_ascent > height { return None; } } self.line_top += line_height; - if line_y < 0.0 { + if line_y + layout_line.max_descent < 0.0 { continue; }