diff --git a/render-wasm/src/render.rs b/render-wasm/src/render.rs index f681d29fba..423d41f17a 100644 --- a/render-wasm/src/render.rs +++ b/render-wasm/src/render.rs @@ -19,7 +19,7 @@ use options::RenderOptions; use surfaces::{SurfaceId, Surfaces}; use crate::performance; -use crate::shapes::{modified_children_ids, Corners, Shape, StructureEntry, Type}; +use crate::shapes::{modified_children_ids, Corners, Shape, StrokeKind, StructureEntry, Type}; use crate::tiles::{self, TileRect, TileViewbox, TileWithDistance}; use crate::uuid::Uuid; use crate::view::Viewbox; @@ -441,13 +441,21 @@ impl RenderState { self.fonts.font_collection(), ); shadows::render_text_drop_shadows(self, &shape, &stroke_paragraphs, antialias); - text::render( - self, - &shape, - &stroke_paragraphs, - Some(SurfaceId::Strokes), - None, - ); + if stroke.kind == StrokeKind::Inner { + // Inner strokes must be rendered on the Fills surface because their blend modes + // (e.g., SrcATop, DstOver) rely on the text fill already being present underneath. + // Rendering them on a separate surface would break this blending and result in incorrect visuals as + // black color background. + text::render(self, &shape, &stroke_paragraphs, None, None); + } else { + text::render( + self, + &shape, + &stroke_paragraphs, + Some(SurfaceId::Strokes), + None, + ); + } shadows::render_text_inner_shadows(self, &shape, &stroke_paragraphs, antialias); } diff --git a/render-wasm/src/render/text.rs b/render-wasm/src/render/text.rs index 0bec6887d2..d6346b29a0 100644 --- a/render-wasm/src/render/text.rs +++ b/render-wasm/src/render/text.rs @@ -8,13 +8,19 @@ pub fn render( surface_id: Option, paint: Option, ) { + let use_save_layer = paint.is_some(); let mask_paint = paint.unwrap_or_default(); let mask = SaveLayerRec::default().paint(&mask_paint); let canvas = render_state .surfaces .canvas(surface_id.unwrap_or(SurfaceId::Fills)); - canvas.save_layer(&mask); + // Skip save_layer when no custom paint is provided to avoid isolating content unnecessarily. + // This ensures inner strokes and fills can blend correctly on the same surface. + if use_save_layer { + canvas.save_layer(&mask); + } + for group in paragraphs { let mut offset_y = 0.0; for skia_paragraph in group { @@ -23,5 +29,7 @@ pub fn render( offset_y += skia_paragraph.height(); } } - canvas.restore(); + if use_save_layer { + canvas.restore(); + } }