Count layout_runs instead of using visible_lines in text::Pipeline::prepare

This commit is contained in:
Héctor Ramón Jiménez 2023-02-04 06:50:38 +01:00
parent 0a324f0aeb
commit a7580e0696
No known key found for this signature in database
GPG key ID: 140CC052C94F138E

View file

@ -176,14 +176,15 @@ impl Pipeline {
let x = section.bounds.x * scale_factor; let x = section.bounds.x * scale_factor;
let y = section.bounds.y * scale_factor; let y = section.bounds.y * scale_factor;
let max_width = buffer let (total_lines, max_width) = buffer
.layout_runs() .layout_runs()
.fold(0.0f32, |max, run| max.max(run.line_w)); .enumerate()
.fold((0, 0.0), |(_, max), (i, buffer)| {
(i + 1, buffer.line_w.max(max))
});
let total_height = buffer.visible_lines() as f32 let total_height =
* section.size total_lines as f32 * section.size * 1.2 * scale_factor;
* 1.2
* scale_factor;
let left = match section.horizontal_alignment { let left = match section.horizontal_alignment {
alignment::Horizontal::Left => x, alignment::Horizontal::Left => x,