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; }