summaryrefslogtreecommitdiffstats
path: root/wgpu/src/text.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-02-04 06:50:38 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-02-24 13:22:58 +0100
commita7580e0696a1a0ba76a89db3f78bc99ba3fbb361 (patch)
treeb75ceebccc79f0785d7854935e99f47fb999e96c /wgpu/src/text.rs
parent0a324f0aebdee06c9cce8ef107b44b847dace05b (diff)
downloadiced-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/src/text.rs')
-rw-r--r--wgpu/src/text.rs13
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,