render: text effects from a paragraph's defRPr or the default text style need filters

`text_has_effects` missed a shadow or glow that text inherits from its
paragraph's `a:pPr/a:defRPr` or the presentation's default text style.
Such a slide was drawn on the multi-threaded vello_cpu dispatcher, which
panics on filter layers; the render guard caught it and the slide came
out blank. Found by the Text Shadow UI test in #1691.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ljkxandClaude Opus 5.5 committed 2026-11-12 19:57:53 +01:00
1 parent 9b1fe3ff23
commit 53044b2ceb
2 files changed
+23 -3

No files matched your search

+5 -3
View File
@@ -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
+18
View File
@@ -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();