Skip to content

enkore/resvg

 
 

Repository files navigation

resvg

Build Status Crates.io Documentation

resvg is an SVG rendering library.

Purpose

resvg can be used as:

too render SVG files based on a static SVG Full 1.1 subset (see SVG support for details).

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

SVG can be rendered to a raster image or to a backend's canvas (like to QWidget via QPainter).

Why a new library?

resvg is trying to compete with librsvg, QtSvg and Inkscape (only as a CLI SVG to PNG converter).

One of the main differences from other rendering libraries is that resvg does a lot of preprocessing before rendering. It converts shapes to paths, resolves attributes, removes groups and invisible elements, fixes a lot of issues in malformed SVG files. Then it creates a simple rendering tree with all elements and attributes resolved. And only then starts to render. So it's very easy to implement a new rendering backend.

More details here.

resvg vs librsvg

librsvg is the main competitor to the resvg. And even though that librsvg itself is being rewritten in Rust, as resvg, the architecture of the library is completely different:

  • librsvg, currently, is heavily tied to cairo library, unlike resvg
  • librsvg is heavily tied to GNOME which makes it painful to distribute outside the Linux ecosystem
  • librsvg doesn't really preprocess input files, rendering them as is
  • librsvg has a minimal support of the edge-cases, which leads to rendering errors

resvg vs Inkscape

Inkscape is often used to convert SVG to PNG, but it's not an actual competitor to resvg, because it's still a complete SVG editor, not a tiny library. Also, it's very slow. But it has the best SVG support amongst others.

resvg vs QtSvg

Without a doubt, QtSvg is heavily used in Qt applications. But QtSvg itself is very limited. It officially supports only a tiny portion of the SVG Tiny 1.2 subset. In simple terms - it correctly renders only primitive SVG images.

SVG support

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

Also, filter, marker, textPath and embedded fonts are not yet implemented.

Results of the static subset of the SVG test suite:

Chart1

Results of the resvg test suite:

Chart2

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

Performance

Chart3

  • librsvg is slower than resvg because Oxygen Icon Theme is using Gaussian blur heavily, which is expensive.
  • QtSvg is fast because it doesn't support Gaussian blur, clipPath, mask and pattern that are heavily used in the Oxygen Icon Theme.
  • Inkscape and Batik are slow just because.
  • More details.

Backends

resvg supports Qt and cairo backends.

Project structure

  • resvg - rendering backends implementation

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

Build

See docs/build.md for details.

License

resvg is licensed under the MPLv2.0.

About

An SVG rendering library.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 80.0%
  • C++ 7.5%
  • C 6.6%
  • Python 5.6%
  • QMake 0.3%