From 9d9450a207a474c40bf1f54e277cdcc8617d6489 Mon Sep 17 00:00:00 2001 From: Friz64 Date: Fri, 10 Nov 2023 20:03:26 +0100 Subject: [PATCH] Fix transparency in ab_glyph renderer --- src/title/ab_glyph_renderer.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/title/ab_glyph_renderer.rs b/src/title/ab_glyph_renderer.rs index 2b2d4b3..e049359 100644 --- a/src/title/ab_glyph_renderer.rs +++ b/src/title/ab_glyph_renderer.rs @@ -93,6 +93,10 @@ impl AbGlyphTitleText { let left = bounds.min.x as u32; let top = bounds.min.y as u32; outline.draw(|x, y, c| { + // `ab_glyph` may return values greater than 1.0, but they are defined to be + // same as 1.0. For our purposes, we need to contrain this value. + let c = c.min(1.0); + let p_idx = (top + y) * width + (left + x); let old_alpha_u8 = pixels[p_idx as usize].alpha(); let new_alpha = c + (old_alpha_u8 as f32 / 255.0);