Exclude line y offset in height comparison
We start `line_y` at an initial offset, so we need to account for this later when checking if the total height is beyond the buffer height.
This commit is contained in:
parent
9a4d067f9d
commit
6a656e9a0f
1 changed files with 6 additions and 2 deletions
|
|
@ -207,7 +207,7 @@ impl<'a, 'b> LayoutRunIter<'a, 'b> {
|
|||
line_i: 0,
|
||||
layout_i: 0,
|
||||
remaining_len: bottom_cropped_layout_lines as usize,
|
||||
line_y: buffer.metrics.font_size - buffer.metrics.line_height,
|
||||
line_y: buffer.metrics.y_offset(),
|
||||
total_layout: 0,
|
||||
}
|
||||
}
|
||||
|
|
@ -234,7 +234,7 @@ impl<'a, 'b> Iterator for LayoutRunIter<'a, 'b> {
|
|||
}
|
||||
|
||||
self.line_y += self.buffer.metrics.line_height;
|
||||
if self.line_y > self.buffer.height {
|
||||
if self.line_y - self.buffer.metrics.y_offset() > self.buffer.height {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
@ -281,6 +281,10 @@ impl Metrics {
|
|||
line_height: self.line_height * scale,
|
||||
}
|
||||
}
|
||||
|
||||
fn y_offset(&self) -> i32 {
|
||||
self.font_size - self.line_height
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Metrics {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue