summaryrefslogtreecommitdiffstats
path: root/tiny_skia/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2023-12-02 16:10:42 +0100
committerLibravatar GitHub <noreply@github.com>2023-12-02 16:10:42 +0100
commit8727b3fc50ec251d9c117c51ca1289be5ba9b117 (patch)
tree802fef9f0b54b6f9cbbeedff14d7f57169db7d6b /tiny_skia/src
parent7f8b17604a31e00becc43130ec516c1a53552c88 (diff)
parentb526ce4958b28208395276dd4078ffe0d780e1d7 (diff)
downloadiced-8727b3fc50ec251d9c117c51ca1289be5ba9b117.tar.gz
iced-8727b3fc50ec251d9c117c51ca1289be5ba9b117.tar.bz2
iced-8727b3fc50ec251d9c117c51ca1289be5ba9b117.zip
Merge pull request #2154 from iced-rs/fix/text-clipping
Fix text clipping
Diffstat (limited to 'tiny_skia/src')
-rw-r--r--tiny_skia/src/backend.rs14
-rw-r--r--tiny_skia/src/geometry.rs15
2 files changed, 16 insertions, 13 deletions
diff --git a/tiny_skia/src/backend.rs b/tiny_skia/src/backend.rs
index f2905b00..3e9bd2a5 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,10 @@ impl Backend {
paragraph,
position,
color,
+ clip_bounds: text_clip_bounds,
} => {
let physical_bounds =
- (Rectangle::new(*position, paragraph.min_bounds)
- + translation)
- * scale_factor;
+ (*text_clip_bounds + translation) * scale_factor;
if !clip_bounds.intersects(&physical_bounds) {
return;
@@ -387,10 +386,10 @@ impl Backend {
editor,
position,
color,
+ clip_bounds: text_clip_bounds,
} => {
let physical_bounds =
- (Rectangle::new(*position, editor.bounds) + translation)
- * scale_factor;
+ (*text_clip_bounds + translation) * scale_factor;
if !clip_bounds.intersects(&physical_bounds) {
return;
@@ -418,9 +417,10 @@ impl Backend {
horizontal_alignment,
vertical_alignment,
shaping,
+ clip_bounds: text_clip_bounds,
} => {
let physical_bounds =
- (primitive.bounds() + translation) * scale_factor;
+ (*text_clip_bounds + 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..5f28b737 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,
+ clip_bounds: Rectangle::with_size(Size::INFINITY),
});
}