From 1bc7e48146b61787f454320023e714fecd09cee7 Mon Sep 17 00:00:00 2001 From: Daniel Yoon <101683475+Koranir@users.noreply.github.com> Date: Wed, 14 Feb 2024 09:03:25 +1100 Subject: [PATCH] Update text.rs --- tiny_skia/src/text.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tiny_skia/src/text.rs b/tiny_skia/src/text.rs index 8f36f95586..d28cc4835f 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, );