resvg

Build Status Crates.io Documentation

resvg is an SVG rendering library.

Purpose

resvg can be used as:

to render SVG files based on a static SVG Full 1.1 subset to raster images or to a backend's canvas (e.g. to a QWidget via QPainter).

The core idea is to make a fast, small, portable, multiple-backend SVG library designed for edge-cases.

Another major difference from other SVG rendering libraries is that resvg does a lot of preprocessing before rendering. It converts an input SVG into a simplified one called Micro SVG and only then it begins rendering. So it's very easy to implement a new rendering backend. And you can also access Micro SVG as XML directly via usvg tool.

SVG support

resvg is aiming to support only the static SVG subset; e.g. no a, script, view or cursor elements, no events and no animations.

A list of unsupported features can be found here.

SVG Tiny 1.2 and SVG 2.0 are not supported and not planned.

Results of the resvg test suite:

Chart2

You can find a complete table of supported features here. It also includes alternative libraries.

Results of the static subset of the SVG test suite:

Chart1

Performance

Comparing performance between different SVG rendering libraries is like comparing apples and oranges. Everyone has a very different set of supported features, implementation languages, build flags, etc. You should do the benchmarks by yourself, on your images.

Because of that, we are only comparing the relative performance between resvg backends, so you can choose the one by yourself. Also, it helps with regression testing. But you should note, that results still may vary depending on OS, hardware, and backend's underlying library version.

Chart3

Chart4

The tests above we run on a single thread on Gentoo Linux with AMD 3700X and inside tmpfs. You can find the script here.

Used libraries: cairo 1.16.0, Qt 5.13.2, raqote 0.6.1, Skia m76

For more specific details checkout benches/README.md

Project structure

All other dependencies aren't written by me for this project.

Directory structure

Safety

Testing

We are using regression testing to test resvg.

Basically, we will download a previous resvg version and check that the new one produces the same results (excluding the expected changes).

The downside of this method is that you need a network connection. On the other hand, we have 4 backends and each of them will produce slightly different results since there is no single correct 2D rendering technique. Bézier curves flattening, gradients rendering, bitmaps scaling, anti-aliasing - they are all backend-specific.
Not to mention the text rendering. We don't use the system fonts rendering, but a list of available, default fonts will still affect the results.

So a regression testing looks like the best choice between manual testing and overcomplicated automatic one. And before each release I'm testing all files manually anyway.

See testing-tools/regression/README.md for more details.

Also, the test files itself are located at the svg-tests directory.

License

resvg is licensed under the MPLv2.0.