diff --git a/crates/render/src/slide.rs b/crates/render/src/slide.rs index b3e6e5dec..2630bb9a5 100644 --- a/crates/render/src/slide.rs +++ b/crates/render/src/slide.rs @@ -37,18 +37,20 @@ pub fn needs_filters(pres: &Presentation, slide: &Slide) -> bool { any } -/// Does the shape's text have a shadow or glow (on a run, in its list style, or in the master's -/// text styles it inherits)? Such text is blurred, which needs filters. +/// Does the shape's text have a shadow or glow (on a run, in its paragraph's `defRPr`, in its list +/// style, or in the master's or presentation's text styles it inherits)? Such text is blurred, +/// which needs filters. fn text_has_effects(rctx: &Ctx, s: &Shape) -> bool { use deckcraft_model::text::{ListStyle, RunProps}; let fx = |r: &RunProps| r.shadow.as_ref().is_some_and(|s| !s.inner) || r.glow.as_ref().is_some_and(|g| g.radius > 0.0); let styled = |l: &ListStyle| l.levels.iter().flatten().any(|lv| fx(&lv.run)); let Some(t) = &s.text else { return false }; - t.paragraphs.iter().any(|p| p.runs.iter().any(|r| fx(&r.props)) || fx(&p.end_props)) + t.paragraphs.iter().any(|p| p.runs.iter().any(|r| fx(&r.props)) || fx(&p.end_props) || fx(&p.def_props)) || styled(&t.list_style) || styled(&rctx.master.title_style) || styled(&rctx.master.body_style) || styled(&rctx.master.other_style) + || styled(&rctx.pres.default_text_style) } /// Render slide `index` at `opts.scale` pixels per point. A panic inside the renderer becomes a diff --git a/crates/render/src/tests.rs b/crates/render/src/tests.rs index e5cd2319e..a35500950 100644 --- a/crates/render/src/tests.rs +++ b/crates/render/src/tests.rs @@ -1239,6 +1239,24 @@ fn effect_text(set: impl Fn(&mut deckcraft_model::text::RunProps)) -> Presentati deck_with(vec![sh]) } +/// Text whose glow comes only from its paragraph's `defRPr` needs the filters too: drawn on the +/// worker threads it panicked (vello_cpu has no filters there) and the slide came out blank. +#[test] +fn a_paragraph_default_text_glow_needs_filters() { + let mut sh = Shape { id: ShapeId(741), xfrm: Some(Xfrm::new(100.0, 100.0, 600.0, 300.0)), text_box: true, ..Default::default() }; + let mut t = TextBody::from_text("IIII"); + let p = &mut t.paragraphs[0]; + p.runs[0].props.size = Some(100.0); + p.runs[0].props.fill = Some(deckcraft_model::style::Fill::solid(ColorRef::rgb(deckcraft_color::Rgba::rgb(0, 0, 0)))); + p.def_props.glow = Some(deckcraft_model::style::Glow { color: ColorRef::rgb(deckcraft_color::Rgba::rgb(0, 255, 0)), radius: 8.0 }); + sh.text = Some(t); + let deck = deck_with(vec![sh]); + assert!(needs_filters(&deck, &deck.slides[0])); + let img = render_slide(&deck, 0, &RenderOpts { scale: 1.0, threads: 4, ..Default::default() }); + let halo = img.pixels.as_chunks::<4>().0.iter().filter(|p| p[1] > 150 && p[0] < 120 && p[2] < 120).count(); + assert!(halo > 300, "green halo pixels {halo}"); +} + #[test] fn text_glow_and_shadow_are_drawn() { let count = |img: &Image, f: &dyn Fn(&[u8; 4]) -> bool| img.pixels.as_chunks::<4>().0.iter().filter(|px| f(px)).count();