Learn/Remade with Rust

rusty_svgtree: SVG Rendering in Rust Without resvg

rusty_svgtree 0.1.0 parses SVG into a simple render tree and draws it with rusty_raster. Hostile files error or clamp. Filters are not in yet.

Signed by M·
A painted drafting table where a pencil plan of a small house lies beside a finished watercolor of the same house, the lines of one carried into the colors of the other
What is rusty_svgtree and what does it replace?

rusty_svgtree parses SVG into a simplified render tree and renders it with rusty_raster, in Rust with Apache-2.0 licensing. It replaces resvg and usvg for the features it covers. SVG filters are not implemented yet.

SVG looks like a text file, and it is one, but rendering it is closer to running a small layout engine. A renderer has to resolve CSS, follow references between elements, apply nested transforms, honor a viewBox, compute clip paths and masks, and decode any pictures embedded inside. All of that comes from whoever wrote the file, which on the web means anyone. rusty_svgtree does that work in Rust: it parses SVG into a simplified render tree, then draws the tree with rusty_raster.

The crate went live on 20 November 2026 under Apache-2.0. For the features it covers, it replaces resvg and its parser, usvg. Two gaps come first, because they decide whether it fits a given job. SVG filters are not implemented. And resvg was 1.91× faster on the 98 corpus files both libraries render identically. Its code is in the monorepo under crates/rusty_svgtree, the Remade with Rust card gives the summary, and MATA's landing covers how it is used.

Trust is an icon or diagram that renders on your own machine. Security is a parser where hostile input errors or clamps. Incentive is honest scope: you can see what is missing before you depend on it.

Why an SVG Renderer Needs a Hardened Input Path

The W3C SVG specification is large, and real files use the generous parts of it. A use element can point at another element that points back. Transforms nest without limit. A stroke width or gradient stop can hold an absurd value. Each of those is a way for a crafted file to exhaust memory, loop forever or push numbers the drawing code was never meant to see. That is why the crate treats every document as hostile: values that make no sense get clamped, and structures that cannot be rendered return an error.

The NIST Secure Software Development Framework asks teams to treat parsing of outside input as a security boundary. CISA's memory safe roadmaps add the language half of that advice. Rust provides the memory safety, and the clamp-or-error rule covers the logic bugs memory safety alone cannot stop.

What the Render Tree Holds

Parsing and drawing are split on purpose. The parser turns messy SVG into a small tree of things a rasteriser understands, and the rasteriser never sees raw SVG.

Paths, Shapes, Transforms and viewBox

Paths and the basic shapes, such as rectangles, circles and polygons, are both supported, and both reach the drawing layer as geometry it can fill and stroke. Transforms are carried into the tree, and the viewBox sets how the document's coordinates map onto the output size, so a logo scales cleanly from a favicon to a poster.

CSS, Gradients, use and symbol

Style can live in attributes, inline style or a stylesheet, and the parser resolves it to concrete fills and strokes. Gradients become paint. use and symbol let one drawing reuse another, which is how icon sets keep their files small. Those references are resolved under the same clamp-or-error rule as everything else in the document.

Clip Paths, Masks, Opacity and Embedded Images

Clip paths and masks control where paint lands, and group opacity fades a whole group together the way the specification requires. Embedded PNG and JPEG images inside the SVG are decoded and placed in the tree. Filters such as blur and drop shadow are the part not built yet.

Where It Fits, and Where resvg Still Wins

Picking a renderer means knowing both columns. This crate wins on input hardening and on sharing one audited drawing layer with the rest of the media stack. resvg wins on speed and on filter support today.

The 1.91x Gap

On the 98 corpus files that both libraries render identically, resvg was 1.91× faster. That figure is the comparison that matters, because it only counts files where the output already agrees. There is no claim here of matching resvg's speed, and none should be read into it.

Missing Filters

A file that leans on blur, drop shadow or other filter effects will not render as its author intended. For icons, diagrams, charts and logos, which mostly use paths, fills, gradients and clips, that gap rarely shows. For illustration work it does. The practical test is simple: render the files you actually have, compare against your current renderer, and keep resvg in the build for the few that need a filter. Both libraries can sit in one project while the gap closes, and the clamp-or-error path still protects every file the new parser handles.

Pinning rusty_svgtree

cargo add rusty_svgtree brings in the parser along with its rasteriser. Raster images on either side stay with rusty_png and rusty_jpeg, and the pipeline around everything is remade_ffmpeg_rs. On a Home Computer, previews of downloaded vector files can be drawn locally, and the EFF explains well why local beats hosted. MATA's rebuild catalog lists the rest of the family, and why Remade with Rust matters gives the reason behind it.

FAQ

Short answers already in this article.

Which SVG features does rusty_svgtree support?

Paths and shapes, transforms, viewBox, CSS, gradients, use and symbol, clip paths, masks, group opacity, and embedded PNG and JPEG images. Filters are the missing piece.

Is rusty_svgtree as fast as resvg?

No. On the 98 corpus files that both libraries render identically, resvg was 1.91 times faster. rusty_svgtree's case is safety and a hardened input path, not speed.

What happens when rusty_svgtree gets a hostile SVG file?

Hostile inputs either return an error or have their values clamped. A malicious file does not get to steer the renderer into undefined behavior or take the process down.

Does rusty_svgtree render SVG filters like blur or drop shadow?

Not yet. SVG filters are not implemented in rusty_svgtree 0.1.0, so a file that depends on a filter effect needs resvg for now.

How does rusty_svgtree turn the tree into pixels?

It hands the simplified render tree to rusty_raster, the hardened tiny-skia fork, which does the anti-aliased fills, strokes, gradients and masks.