Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

Respect SVG image-rendering pixelated attribute

Shunsuke Yoshizawaaaeb1b2b35c4
diff --git a/crates/svg/src/import/importer.rs b/crates/svg/src/import/importer.rs
index 2215458e8..c2220f9d8 100644
--- a/crates/svg/src/import/importer.rs
+++ b/crates/svg/src/import/importer.rs
@@ -652,10 +652,16 @@ impl Importer {
if link.is_some() && !missing { blob.with_proxy() } else { blob }
});
let xf = acc * Affine::scale_non_uniform(size.width() as f64 / pw as f64, size.height() as f64 / ph as f64);
- self.named(
+ let mut node = self.named(
i.id(),
NodeKind::Image(Box::new(ImageObject { key, width: pw, height: ph, xf, link, placement: Default::default(), pixels: None })),
- )
+ )?;
+
+ if i.rendering_mode() == usvg::ImageRendering::Pixelated {
+ node.extras_mut().pixelated = true;
+ }
+
+ Some(node)
}
/// An SVG shown as an image (a data URL or a linked file) → its art, `acc` mapping its size.