From d5e68c731c95b5fe366de718a4898e50e5e0525a Mon Sep 17 00:00:00 2001 From: Pg Biel <9021226+PgBiel@users.noreply.github.com> Date: Fri, 28 Apr 2023 05:02:51 -0300 Subject: [PATCH] fix 0pt stroke for PDF export (#1020) --- src/export/pdf/page.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/export/pdf/page.rs b/src/export/pdf/page.rs index e15f3750..acf5062e 100644 --- a/src/export/pdf/page.rs +++ b/src/export/pdf/page.rs @@ -417,7 +417,15 @@ fn write_text(ctx: &mut PageContext, x: f32, y: f32, text: &TextItem) { /// Encode a geometrical shape into the content stream. fn write_shape(ctx: &mut PageContext, x: f32, y: f32, shape: &Shape) { - if shape.fill.is_none() && shape.stroke.is_none() { + let stroke = shape.stroke.as_ref().and_then(|stroke| { + if stroke.thickness.to_f32() > 0.0 { + Some(stroke) + } else { + None + } + }); + + if shape.fill.is_none() && stroke.is_none() { return; } @@ -425,7 +433,7 @@ fn write_shape(ctx: &mut PageContext, x: f32, y: f32, shape: &Shape) { ctx.set_fill(fill); } - if let Some(stroke) = &shape.stroke { + if let Some(stroke) = stroke { ctx.set_stroke(stroke); } @@ -448,7 +456,7 @@ fn write_shape(ctx: &mut PageContext, x: f32, y: f32, shape: &Shape) { } } - match (&shape.fill, &shape.stroke) { + match (&shape.fill, stroke) { (None, None) => unreachable!(), (Some(_), None) => ctx.content.fill_nonzero(), (None, Some(_)) => ctx.content.stroke(),