summaryrefslogtreecommitdiffstats
path: root/tiny_skia
diff options
context:
space:
mode:
authorLibravatar Daniel Yoon <101683475+Koranir@users.noreply.github.com>2024-02-14 09:03:25 +1100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-02-15 03:10:15 +0100
commit7a572655c1302233d5aeb036ec8a71b867326b59 (patch)
tree5ee1b04bfcd0729ba4cc5bbc077329f2d8bc8f7e /tiny_skia
parent84cc9f130b4e29219d47db42cdb76548b054c66b (diff)
downloadiced-7a572655c1302233d5aeb036ec8a71b867326b59.tar.gz
iced-7a572655c1302233d5aeb036ec8a71b867326b59.tar.bz2
iced-7a572655c1302233d5aeb036ec8a71b867326b59.zip
Fix text transparency in `iced_tiny_skia`
Diffstat (limited to 'tiny_skia')
-rw-r--r--tiny_skia/src/text.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/tiny_skia/src/text.rs b/tiny_skia/src/text.rs
index 8f36f955..d28cc483 100644
--- a/tiny_skia/src/text.rs
+++ b/tiny_skia/src/text.rs
@@ -238,6 +238,12 @@ fn draw(
)
.expect("Create glyph pixel map");
+ let opacity = color.a
+ * glyph
+ .color_opt
+ .map(|c| c.a() as f32 / 255.0)
+ .unwrap_or(1.0);
+
pixels.draw_pixmap(
physical_glyph.x + placement.left,
physical_glyph.y - placement.top
@@ -246,7 +252,10 @@ fn draw(
* transformation.scale_factor())
.round() as i32,
pixmap,
- &tiny_skia::PixmapPaint::default(),
+ &tiny_skia::PixmapPaint {
+ opacity,
+ ..tiny_skia::PixmapPaint::default()
+ },
tiny_skia::Transform::identity(),
clip_mask,
);