diff --git a/examples/scenes/src/download.rs b/examples/scenes/src/download.rs index 963a29a3a..a9c5ced54 100644 --- a/examples/scenes/src/download.rs +++ b/examples/scenes/src/download.rs @@ -199,8 +199,13 @@ impl SVGDownload { if reader.read_exact(&mut [0]).is_ok() { bail!("Size limit exceeded"); } - if limit_exact && file.stream_position().context("Checking file limit")? != size_limit { - bail!("Builtin downloaded file was not as expected"); + if limit_exact { + let bytes_downloaded = file.stream_position().context("Checking file limit")?; + if bytes_downloaded != size_limit { + bail!( + "Builtin downloaded file was not as expected. Expected {size_limit}, received {bytes_downloaded}.", + ); + } } Ok(()) } diff --git a/examples/scenes/src/download/default_downloads.rs b/examples/scenes/src/download/default_downloads.rs index 5f6ac3edd..c68407ff8 100644 --- a/examples/scenes/src/download/default_downloads.rs +++ b/examples/scenes/src/download/default_downloads.rs @@ -39,5 +39,65 @@ pub(super) fn default_downloads() -> Vec { url: "https://upload.wikimedia.org/wikipedia/commons/5/58/Coat_of_arms_of_the_Kingdom_of_Yugoslavia.svg".to_string(), name: "Coat of Arms of the Kingdom of Yugoslavia".to_string() }, + SVGDownload { + builtin:Some(BuiltinSvgProps { + info: "https://github.com/RazrFalcon/resvg-test-suite", + license: "MIT", + expected_size: 383, + }), + url: "https://raw.githubusercontent.com/RazrFalcon/resvg-test-suite/master/tests/painting/stroke-dashoffset/default.svg".to_string(), + name: "SVG Stroke Dasharray Test".to_string() + }, + SVGDownload { + builtin:Some(BuiltinSvgProps { + info: "https://github.com/RazrFalcon/resvg-test-suite", + license: "MIT", + expected_size: 342, + }), + url: "https://raw.githubusercontent.com/RazrFalcon/resvg-test-suite/master/tests/painting/stroke-linecap/butt.svg".to_string(), + name: "SVG Stroke Linecap Butt Test".to_string() + }, + SVGDownload { + builtin:Some(BuiltinSvgProps { + info: "https://github.com/RazrFalcon/resvg-test-suite", + license: "MIT", + expected_size: 344, + }), + url: "https://raw.githubusercontent.com/RazrFalcon/resvg-test-suite/master/tests/painting/stroke-linecap/round.svg".to_string(), + name: "SVG Stroke Linecap Round Test".to_string() + }, + SVGDownload { + builtin:Some(BuiltinSvgProps { + info: "https://github.com/RazrFalcon/resvg-test-suite", + license: "MIT", + expected_size: 346, + }), + url: "https://raw.githubusercontent.com/RazrFalcon/resvg-test-suite/master/tests/painting/stroke-linecap/square.svg".to_string(), + name: "SVG Stroke Linecap Square Test".to_string() + }, SVGDownload { + builtin:Some(BuiltinSvgProps { + info: "https://github.com/RazrFalcon/resvg-test-suite", + license: "MIT", + expected_size: 381, + }), + url: "https://github.com/RazrFalcon/resvg-test-suite/raw/master/tests/painting/stroke-linejoin/miter.svg".to_string(), + name: "SVG Stroke Linejoin Bevel Test".to_string() + }, SVGDownload { + builtin:Some(BuiltinSvgProps { + info: "https://github.com/RazrFalcon/resvg-test-suite", + license: "MIT", + expected_size: 381, + }), + url: "https://github.com/RazrFalcon/resvg-test-suite/raw/master/tests/painting/stroke-linejoin/round.svg".to_string(), + name: "SVG Stroke Linejoin Round Test".to_string() + },SVGDownload { + builtin:Some(BuiltinSvgProps { + info: "https://github.com/RazrFalcon/resvg-test-suite", + license: "MIT", + expected_size: 351, + }), + url: "https://github.com/RazrFalcon/resvg-test-suite/raw/master/tests/painting/stroke-miterlimit/default.svg".to_string(), + name: "SVG Stroke Miterlimit Test".to_string() + }, ] } diff --git a/integrations/vello_svg/src/lib.rs b/integrations/vello_svg/src/lib.rs index 2c3940d83..37bb2fd27 100644 --- a/integrations/vello_svg/src/lib.rs +++ b/integrations/vello_svg/src/lib.rs @@ -150,10 +150,28 @@ pub fn render_tree_with Result<(), E>, E>( if let Some((brush, brush_transform)) = paint_to_brush(&stroke.paint, stroke.opacity) { - // FIXME: handle stroke options such as linecap, - // linejoin, etc. + let mut conv_stroke = Stroke::new(stroke.width.get() as f64) + .with_caps(match stroke.linecap { + usvg::LineCap::Butt => vello::kurbo::Cap::Butt, + usvg::LineCap::Round => vello::kurbo::Cap::Round, + usvg::LineCap::Square => vello::kurbo::Cap::Square, + }) + .with_join(match stroke.linejoin { + usvg::LineJoin::Miter | usvg::LineJoin::MiterClip => { + vello::kurbo::Join::Miter + } + usvg::LineJoin::Round => vello::kurbo::Join::Round, + usvg::LineJoin::Bevel => vello::kurbo::Join::Bevel, + }) + .with_miter_limit(stroke.miterlimit.get() as f64); + if let Some(dash_array) = stroke.dasharray.as_ref() { + conv_stroke = conv_stroke.with_dashes( + stroke.dashoffset as f64, + dash_array.iter().map(|x| *x as f64), + ); + } scene.stroke( - &Stroke::new(stroke.width.get() as f64), + &conv_stroke, transform, &brush, Some(brush_transform),