🐛 Fix inner strokes with opacity using erode instead of multiple blending modes

This commit is contained in:
Elena Torro
2025-08-20 13:32:20 +02:00
parent a6ecc4fb3c
commit 9bb92277e4

View File

@@ -740,27 +740,18 @@ fn get_text_stroke_paints(stroke: &Stroke, bounds: &Rect, text_paint: &Paint) ->
set_paint_fill(&mut paint, &stroke.fill, bounds); set_paint_fill(&mut paint, &stroke.fill, bounds);
paints.push(paint); paints.push(paint);
} else { } else {
// outer let mut paint = text_paint.clone();
let mut paint = skia::Paint::default();
paint.set_style(skia::PaintStyle::Stroke);
paint.set_blend_mode(skia::BlendMode::DstATop);
paint.set_anti_alias(true);
paint.set_stroke_width(stroke.width * 2.0);
paints.push(paint);
let mut paint = skia::Paint::default();
paint.set_style(skia::PaintStyle::Fill); paint.set_style(skia::PaintStyle::Fill);
paint.set_blend_mode(skia::BlendMode::Clear); paint.set_anti_alias(false);
paint.set_anti_alias(true); set_paint_fill(&mut paint, &stroke.fill, bounds);
paints.push(paint); paints.push(paint);
// inner
let mut paint = skia::Paint::default(); let mut paint = skia::Paint::default();
paint.set_style(skia::PaintStyle::Stroke); let image_filter =
paint.set_stroke_width(stroke.width * 2.0); skia_safe::image_filters::erode((stroke.width, stroke.width), None, None);
paint.set_blend_mode(skia::BlendMode::Xor); paint.set_image_filter(image_filter);
paint.set_anti_alias(true); paint.set_anti_alias(false);
set_paint_fill(&mut paint, &stroke.fill, bounds); paint.set_blend_mode(skia::BlendMode::DstOut);
paints.push(paint); paints.push(paint);
} }
} }