Fix panic in layout_line when Y coordinate is too high (#9052)

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2024-03-07 22:33:44 -07:00 committed by GitHub
parent af564242e1
commit ed8aa6d200
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -247,10 +247,11 @@ impl WrappedLineLayout {
let wrapped_line_ix = (position.y / line_height) as usize; let wrapped_line_ix = (position.y / line_height) as usize;
let wrapped_line_start_x = if wrapped_line_ix > 0 { let wrapped_line_start_x = if wrapped_line_ix > 0 {
let wrap_boundary_ix = wrapped_line_ix - 1; let Some(line_start_boundary) = self.wrap_boundaries.get(wrapped_line_ix - 1) else {
let wrap_boundary = self.wrap_boundaries[wrap_boundary_ix]; return None;
let run = &self.unwrapped_layout.runs[wrap_boundary.run_ix]; };
run.glyphs[wrap_boundary.glyph_ix].position.x let run = &self.unwrapped_layout.runs[line_start_boundary.run_ix];
run.glyphs[line_start_boundary.glyph_ix].position.x
} else { } else {
Pixels::ZERO Pixels::ZERO
}; };