diff options
author | 2023-09-03 08:08:27 +0200 | |
---|---|---|
committer | 2023-09-03 08:08:27 +0200 | |
commit | 8129e2c208d9b13dbd32a309058b0547c723dede (patch) | |
tree | c9c5d9e383a2956b4e9b5cf7a48a5202fc6f249b /wgpu/src/text.rs | |
parent | 601e5563d101788cbaa6febbe15cdf52e9f3ae9b (diff) | |
download | iced-8129e2c208d9b13dbd32a309058b0547c723dede.tar.gz iced-8129e2c208d9b13dbd32a309058b0547c723dede.tar.bz2 iced-8129e2c208d9b13dbd32a309058b0547c723dede.zip |
Implement `draw_paragraph` in `iced_tiny_skia`
Diffstat (limited to 'wgpu/src/text.rs')
-rw-r--r-- | wgpu/src/text.rs | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index ee352368..a1ec511b 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -159,29 +159,28 @@ impl Pipeline { } }; - let x = bounds.x * scale_factor; - let y = bounds.y * scale_factor; - - let max_width = bounds.width * scale_factor; - let total_height = bounds.height * scale_factor; + let bounds = bounds * scale_factor; let left = match horizontal_alignment { - alignment::Horizontal::Left => x, - alignment::Horizontal::Center => x - max_width / 2.0, - alignment::Horizontal::Right => x - max_width, + alignment::Horizontal::Left => bounds.x, + alignment::Horizontal::Center => { + bounds.x - bounds.width / 2.0 + } + alignment::Horizontal::Right => bounds.x - bounds.width, }; let top = match vertical_alignment { - alignment::Vertical::Top => y, - alignment::Vertical::Center => y - total_height / 2.0, - alignment::Vertical::Bottom => y - total_height, + alignment::Vertical::Top => bounds.y, + alignment::Vertical::Center => { + bounds.y - bounds.height / 2.0 + } + alignment::Vertical::Bottom => bounds.y - bounds.height, }; let section_bounds = Rectangle { x: left, y: top, - width: max_width, - height: total_height, + ..bounds }; let clip_bounds = layer_bounds.intersection(§ion_bounds)?; |