diff options
| author | Pg Biel <9021226+PgBiel@users.noreply.github.com> | 2023-04-23 09:38:12 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-23 14:38:12 +0200 |
| commit | e9a0cf97419b3c7dac0ab74566a921ba255ead37 (patch) | |
| tree | f0d6f044915ba4348f7fea1a91cd922af59552e8 /src | |
| parent | fd5e5b1ebb74b776f6e7f60998e239da5e6bbb61 (diff) | |
Fix 0pt strokes (#923)
Diffstat (limited to 'src')
| -rw-r--r-- | src/export/render.rs | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/src/export/render.rs b/src/export/render.rs index b3a8f5ce..fa7c9454 100644 --- a/src/export/render.rs +++ b/src/export/render.rs @@ -402,28 +402,33 @@ fn render_shape( miter_limit, }) = &shape.stroke { - let dash = dash_pattern.as_ref().and_then(|pattern| { - // tiny-skia only allows dash patterns with an even number of elements, - // while pdf allows any number. - let len = if pattern.array.len() % 2 == 1 { - pattern.array.len() * 2 - } else { - pattern.array.len() + let width = thickness.to_f32(); + + // Don't draw zero-pt stroke. + if width > 0.0 { + let dash = dash_pattern.as_ref().and_then(|pattern| { + // tiny-skia only allows dash patterns with an even number of elements, + // while pdf allows any number. + let len = if pattern.array.len() % 2 == 1 { + pattern.array.len() * 2 + } else { + pattern.array.len() + }; + let dash_array = + pattern.array.iter().map(|l| l.to_f32()).cycle().take(len).collect(); + + sk::StrokeDash::new(dash_array, pattern.phase.to_f32()) + }); + let paint = paint.into(); + let stroke = sk::Stroke { + width, + line_cap: line_cap.into(), + line_join: line_join.into(), + dash, + miter_limit: miter_limit.0 as f32, }; - let dash_array = - pattern.array.iter().map(|l| l.to_f32()).cycle().take(len).collect(); - - sk::StrokeDash::new(dash_array, pattern.phase.to_f32()) - }); - let paint = paint.into(); - let stroke = sk::Stroke { - width: thickness.to_f32(), - line_cap: line_cap.into(), - line_join: line_join.into(), - dash, - miter_limit: miter_limit.0 as f32, - }; - canvas.stroke_path(&path, &paint, &stroke, ts, mask); + canvas.stroke_path(&path, &paint, &stroke, ts, mask); + } } Some(()) |
