resvg is an SVG rendering library.
resvg can be used as:
- a Rust library
- a C library (see capi)
- a CLI application (see tools/rendersvg)
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.
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 static subset of the SVG test suite:
Results of the resvg test suite:
You can find a complete table of supported features here. It also includes alternative libraries.
Note that all tested applications have a different SVG support, which impacts the performance.
Also, we do not test against Chrome, Firefox, Inkscape and Batik because they have a huge startup time.
- Elementary Icon Theme contains 3417 files.
- Qt backend is slow because
QRasterPaintEngineis slow.
- The Oxygen icon theme contains 4947 files.
- All images were converted from
.svgzto.svgbeforehand. resvgis slower thanlibrsvgbecause the Oxygen icon theme uses Gaussian blur heavily, andlibrsvghas a faster blur implementation. Also,librsvguses nativecairoclipping, which is incorrect but faster.- QtSvg doesn't support
filter,clipPath,maskandpatternthat are heavily used in the Oxygen icon theme. So it's actually very slow.
For more details checkout benches/README.md
resvg– rendering backends implementationusvg– an SVG simplification toolresvg-qt– minimal bindings to Qtresvg-skia– minimal bindings to Skia
All other dependencies aren't written by me for this project.
benches- basic benchmarks for rendering operationsbindings– minimal bindings to Qt and Skia used by resvgcapi– C interface for resvgdocs– basic documentationexamples– usage examples for resvg as a librarysrc– source codetesting-tools– scripts used for testingtools– useful toolsusvg– an SVG simplification library used by resvg
- The library must not panic. Any panic should be considered a critical bug and should be reported. There are only a few methods that can produce a panic.
- The core library structure (see above) does not use any
unsafe, but since all backends are implemented via FFI, we are stuck withunsafeanyway. Also,usvguses unsafe for fonts memory mapping.
resvg is licensed under the MPLv2.0.