diff options
author | 2023-02-04 06:50:38 +0100 | |
---|---|---|
committer | 2023-02-24 13:22:58 +0100 | |
commit | a7580e0696a1a0ba76a89db3f78bc99ba3fbb361 (patch) | |
tree | b75ceebccc79f0785d7854935e99f47fb999e96c /wgpu | |
parent | 0a324f0aebdee06c9cce8ef107b44b847dace05b (diff) | |
download | iced-a7580e0696a1a0ba76a89db3f78bc99ba3fbb361.tar.gz iced-a7580e0696a1a0ba76a89db3f78bc99ba3fbb361.tar.bz2 iced-a7580e0696a1a0ba76a89db3f78bc99ba3fbb361.zip |
Count `layout_runs` instead of using `visible_lines` in `text::Pipeline::prepare`
Diffstat (limited to 'wgpu')
-rw-r--r-- | wgpu/src/text.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index 41787136..fa7fd5df 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -176,14 +176,15 @@ impl Pipeline { let x = section.bounds.x * scale_factor; let y = section.bounds.y * scale_factor; - let max_width = buffer + let (total_lines, max_width) = buffer .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 - * section.size - * 1.2 - * scale_factor; + let total_height = + total_lines as f32 * section.size * 1.2 * scale_factor; let left = match section.horizontal_alignment { alignment::Horizontal::Left => x, |