diff options
author | 2023-12-01 16:04:27 +0100 | |
---|---|---|
committer | 2023-12-01 16:04:27 +0100 | |
commit | 936d480267578d7e80675e78ec1880aaaaab72d6 (patch) | |
tree | 70719766c67dd6a09630c5a4231e952a3200bea1 /tiny_skia | |
parent | 99899d49cc93cdec3832f7b5ecad867fdd421e07 (diff) | |
download | iced-936d480267578d7e80675e78ec1880aaaaab72d6.tar.gz iced-936d480267578d7e80675e78ec1880aaaaab72d6.tar.bz2 iced-936d480267578d7e80675e78ec1880aaaaab72d6.zip |
Clip text to `viewport` bounds instead of layout bounds
Diffstat (limited to 'tiny_skia')
-rw-r--r-- | tiny_skia/src/backend.rs | 17 | ||||
-rw-r--r-- | tiny_skia/src/geometry.rs | 15 |
2 files changed, 16 insertions, 16 deletions
diff --git a/tiny_skia/src/backend.rs b/tiny_skia/src/backend.rs index f2905b00..cc0f72d1 100644 --- a/tiny_skia/src/backend.rs +++ b/tiny_skia/src/backend.rs @@ -1,6 +1,6 @@ use crate::core::{Background, Color, Gradient, Rectangle, Vector}; use crate::graphics::backend; -use crate::graphics::{Damage, Viewport}; +use crate::graphics::Viewport; use crate::primitive::{self, Primitive}; use std::borrow::Cow; @@ -361,11 +361,9 @@ impl Backend { paragraph, position, color, + viewport, } => { - let physical_bounds = - (Rectangle::new(*position, paragraph.min_bounds) - + translation) - * scale_factor; + let physical_bounds = (*viewport + translation) * scale_factor; if !clip_bounds.intersects(&physical_bounds) { return; @@ -387,10 +385,9 @@ impl Backend { editor, position, color, + viewport, } => { - let physical_bounds = - (Rectangle::new(*position, editor.bounds) + translation) - * scale_factor; + let physical_bounds = (*viewport + translation) * scale_factor; if !clip_bounds.intersects(&physical_bounds) { return; @@ -418,9 +415,9 @@ impl Backend { horizontal_alignment, vertical_alignment, shaping, + viewport, } => { - let physical_bounds = - (primitive.bounds() + translation) * scale_factor; + let physical_bounds = (*viewport + translation) * scale_factor; if !clip_bounds.intersects(&physical_bounds) { return; diff --git a/tiny_skia/src/geometry.rs b/tiny_skia/src/geometry.rs index 1d14aa03..b73f84a9 100644 --- a/tiny_skia/src/geometry.rs +++ b/tiny_skia/src/geometry.rs @@ -109,15 +109,17 @@ impl Frame { Point::new(transformed[0].x, transformed[0].y) }; + let bounds = Rectangle { + x: position.x, + y: position.y, + width: f32::INFINITY, + height: f32::INFINITY, + }; + // TODO: Use vectorial text instead of primitive self.primitives.push(Primitive::Text { content: text.content, - bounds: Rectangle { - x: position.x, - y: position.y, - width: f32::INFINITY, - height: f32::INFINITY, - }, + bounds, color: text.color, size: text.size, line_height: text.line_height, @@ -125,6 +127,7 @@ impl Frame { horizontal_alignment: text.horizontal_alignment, vertical_alignment: text.vertical_alignment, shaping: text.shaping, + viewport: bounds, }); } |