From 62569f8a9d6be436bbf88ab78b29a54c2b2ebcb9 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sun, 4 Oct 2026 22:02:26 +0700 Subject: [PATCH] M3.19: a negative dash entry makes the pattern invalid, so the line draws solid The merged dasher clamped negative entries to zero, which turned [-5, 3] into dots instead of the solid line SVG and PDF draw for an invalid pattern (render test invalid_dash_pattern_strokes_solid). Co-Authored-By: Claude Opus 5.5 --- crates/effects/src/stroke/dash.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/effects/src/stroke/dash.rs b/crates/effects/src/stroke/dash.rs index a5d8ce00..16590f59 100644 --- a/crates/effects/src/stroke/dash.rs +++ b/crates/effects/src/stroke/dash.rs @@ -27,13 +27,14 @@ pub struct Dashed { pub dots: Vec, } -/// Apply dash pattern `d` to `bp`. `None` when the pattern has no positive length (the line is -/// solid) or is too fine to draw (then the line is drawn solid too). +/// Apply dash pattern `d` to `bp`. `None` when the pattern is invalid (a negative or non-finite +/// entry, as in SVG and PDF) or has no positive length (the line is solid), or is too fine to draw +/// (then the line is drawn solid too). pub fn dash(bp: &BezPath, d: &Dash) -> Option { - if d.pattern.iter().any(|v| !v.is_finite()) || !d.offset.is_finite() { + if d.pattern.iter().any(|v| !v.is_finite() || *v < 0.0) || !d.offset.is_finite() { return None; } - let mut pat: Vec = d.pattern.iter().map(|v| v.max(0.0)).collect(); + let mut pat = d.pattern.clone(); if !pat.iter().any(|v| *v > MIN_ENTRY) { return None; }