An SVG rendering library.

Related tags

Graphics svg render


Build Status Documentation

resvg is an SVG rendering library.


resvg can be used as a Rust library, a C library and as a CLI application to render SVG files based on a static SVG Full 1.1 subset.

The core idea is to make a fast, small, portable SVG library designed for edge-cases. Right now, a resvg CLI application is less than 3MiB and doesn't require any external dependencies.

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. But we officially support only one. And you can also access Micro SVG as XML directly via the 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.

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

Results of the resvg test suite:

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


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. But since resvg is written in Rust and uses tiny-skia for rendering - it's pretty fast.


resvg and most of its dependencies are pretty safe. The main exceptions are tiny-skia and files memory mapping.


resvg project is licensed under the MPLv2.0.

  • Raqote backend

    Raqote backend


    • [x] Ugly stroking: e-image-003 (especially S), e-image-017, e-image-022 (clearly visible) (raqote bug)
    • [x] a-stroke-dasharray-004 (raqote bug)
    • [x] a-stroke-linecap-004 (should be done on the resvg size)
    • [x] a-stroke-linecap-005 (should be done on the resvg size)
    • [x] e-clipPath-019
    • [x] e-feBlend-002 (raqote bug, BlendMode::Multiply produce nothing)
    • [x] e-image-010 (raqote bug? Looks like some issue with a pattern.)
    • [x] e-mask-007 (~~raqote bug? Looks like something is wrong with clip~~)
    • [x] e-path-013 (raqote bug)
    • [x] e-radialGradient-011 (raqote bug)
    • [x] e-radialGradient-029
    • [x] ~~e-stop-016 (raqote bug)~~
    • [x] Markers are very slow, aka multiple sublayers.
    • [x] Optional anti-aliasing.

    Closes #134

    opened by RazrFalcon 84
  • C-API `resvg_options_set_font_family` doesn't work in release v0.28.0

    C-API `resvg_options_set_font_family` doesn't work in release v0.28.0

    Hello, I tried to use the function in my C++ project as I've done before, but when rendering the svg, text is not displayed after providing a font and calling the function with the font family. This used to work in releases before v0.28.0.

    I see in the commit history that this function was removed then added back, so maybe something was missed when reverting that change?

    The C++ project I'm referring to is: and the line where I'm using the function is:

    opened by ANSH3LL 26
  • Add a way to enumerate fonts used in a SVG before rendering

    Add a way to enumerate fonts used in a SVG before rendering

    Loading fonts can be a pretty expensive operation, especially on targets like JS/Wasm, where there is no mmap-like feature, and one must load fonts asynchronously before invoking resvg.

    To optimise this case, it would be handy if usvg provided a way to get set of fonts used in the SVG document before rendering it to the final form. That way, resvg-js users, as well as native ones, could only load fonts that will be definitely necessary for rendering the document.

    I'm not sure how feasible this is given that usvg downcasts text to shapes as part of its processing, but maybe it could preserve text nodes in some intermediate form to give user the chance to do this async loading?

    opened by RReverser 23
  • Render text in wasm32-unknown-unknown

    Render text in wasm32-unknown-unknown

    usvg currently works great in wasm environments as long as the optional "text" feature is disabled. I'd love to get text support working too. From my understanding so far, there are at least 3 issues:

    • a dependency on memmap2, used for reading fonts
    • reading fonts from system directories (#202)
    • a dependency on harfbuzz

    The first two are relatively straightforward. As part of #202, design an API to feed a FontDB into usvg that can be instantiated many different ways, one of them just being raw bytes of a font file. (include_bytes! is a low-effort way to get this working in a wasm environment.)

    The harfbuzz dependency seems harder. My requirements are limited to simple Latin left-to-right text; harfbuzz is overkill. I found font2svg and think it might be possible to make something much simpler. Before I go down this rabbit hole, I wanted to ask for your advice.


    I'm using usvg in A/B Street to turn both normal SVG files and text into paths for lyon, which then give me polygons. This does the usvg->lyon->my simple Polygon abstraction path, based off this example from lyon. I'm using this same pipeline for text as well. (There are many inefficient and silly things that the text pipeline does right now, like constantly re-load fonts.) In a few weeks, I'm hoping to properly split off my drawing, geometry, and GUI libraries as new crates for other people to use. These libraries attempt to give exactly the same experience on native and web -- not using system UI controls/style -- without any changes to user code needed for different platforms.

    opened by dabreegster 21
  • Support SVG Native

    Support SVG Native

    There is recent work to define an SVG Native spec, which is a subset of SVG 1.1. Adobe recently published a SVG Native Viewer library (C++ 11), and the FreeType project is considering resvg among the candidates as the backend for rendering OpenType+SVG fonts.

    I wonder how resvg relates to SVG Native, and if you have any plans to provide full compatibility to the SVG Native profile?


    There are some tools that allow people to make OpenType+SVG fonts

    opened by twardoch 19
  • Benchmark on something other than icons

    Benchmark on something other than icons

    Benchmarking on icons only is not particularly representative of performance in general.

    I've tried rendering Inkscape about screens as they're bigger than icons and represent a wide variety of SVG feature combinations, using more advanced features over time as Inkscape itself evolved.

    On my machine resvg takes 1 second to render them all while librsvg takes 5 seconds. I've blacklisted 0.48 splash screen as it has some unsupported filters. librsvg also renders the 0.92 splash screen incorrectly, while resvg works fine.

    opened by Shnatsel 18
  • Support rendering parts/tiles of an SVG, repeatedly

    Support rendering parts/tiles of an SVG, repeatedly


    I.e. I only want the lower left quadrant of the image I would specify a ViewBox with a Rect::new(0.5, 0.5, 0.5, 0.5). FitTo would then pertain to the size of that region, not the total canvas.


    I am looking into adding support for SVG textures to a 3D renderer. During render time the renderer will request texture tiles at certain resolutions. These tiles are the aforementioned sub images.

    Another use case is a viewer that e.g. allows zooming. When you zoom in 10000 times you do not want to be forced to render the whole canvas but only the visible portion.


    ~~It would be best if this worked by creating some sort of persistent representation of the SVG that can be queried for such 'sub' Pixmaps to keep any initial set-up/overhead of parsing etc. a one time cost.~~

    ~~I.e. you would create an SVG struct and call render_region() or the like on it, repeatedly.~~

    I guess this already works efficiently when querying the same Tree/Node repeatedly?

    opened by virtualritz 17
  • Skia backend

    Skia backend


    • [x] Sync with master.
    • [ ] e-pattern-18
    • [ ] e-marker-22 is very slow
    • [x] Support older Skia.
    • [x] Update BUILD.adoc
    • [x] Test on all platforms.
    • [ ] ~~Test on CI.~~

    Closes #44

    opened by RazrFalcon 17
  • Support providing a separate fontdb

    Support providing a separate fontdb

    I would like to provide my own set of fonts with my application (as binary objects) and not reply on any system fonts at all. Is there a way to skip all system font resolution and to provide a font manually?

    opened by hjmallon 16
  • Use Skia Canvas instead of Surface where possible

    Use Skia Canvas instead of Surface where possible

    Hey, I've made some changes to allow you to use Skia's Canvas wherever possible. This allows you to use resvg with PDFs 🎉.

    The SkPDF backend uses SkDocument instead of SkSurface, since a document must include multiple pages.

    Something like this:

    let pdf_doc = skia::PDF::make_document(&pdf_stream);
    let pdf_canvas = pdf_doc.begin_page(width, height);
    resvg::backend_skia::render_to_canvas(&tree, &opt, size, pdf_canvas);
    opened by therealbnut 16
  • If font-family is not found, no text is rendered

    If font-family is not found, no text is rendered

    Hi, this is really more of a question than a bug probably. I am setting up a new Windows 10 build server for OpenShot, and noticed that resvg.dll does not render any text. It does in fact render other shapes, gradients, and lines just fine... but anywhere "text" is supposed to be, it renders nothing.

    git clone
    cd resvg/capi
    QT_DIR="C:\\msys64\\mingw64\\" cargo build --verbose --release --features="qt-backend"

    I compiled resvg on MSYS2 (using the latest version of Qt 5.12.4). No errors were reported during the build. I was also able to link to it with no issues. When OpenShot renders a SVG file though, all text is missing.

    So, just curious if this rings a bell or if this is something silly on my part, missing a dependency, etc... If not, what do you suggest as the best way to troubleshoot an issue like this? Thank again!

    opened by jonoomph 16
  • usvg cannot write an SVG anymore. Is there an alternative?

    usvg cannot write an SVG anymore. Is there an alternative?

    Since writing SVG has been removed, is there an alternative for this functionality? Maybe an external crate?

    If not, are there any plans to bring it back?

    opened by Gei0r 2
  • Build instructions

    Build instructions

    Please consider adding build instructions to resvg and usvg showing people how to build a binary using rust/Cargo. (I tried for about 30 minutes before giving up.)

    opened by DaveJarvis 9
  • Figure out how to implement custom markers paint order

    Figure out how to implement custom markers paint order

    Since usvg converts markers into regular nodes, we cannot render them between path's fill and stroke. Which is allowed by the spec. We can render them only below or above the path.

    The only way to implement this is by rewriting markers support. Basically removing this simplification step from usvg, which is unfortunate.

    opened by RazrFalcon 0
  • Anti-aliased edges of patterns with non-integer width/height

    Anti-aliased edges of patterns with non-integer width/height

    Hallo, I've noticed that patterns result in some anti-aliasing issues at the edges, if they have non-integer dimensions and the shapes inside the pattern go right against the edge.

    To illustrate the case I made a large white rectangle covered by a rectangle on top, which has a pattern of 20.13x20.13 containing just a black rectangle filling the pattern exactly. In the PNG result you can see the white shining through, but the whole area should be black. (Note: the viewBox is only 0 0 200 200, but the image has to be larger to see the effect, so its width and height are set to 1000)

    Any of these workarounds make it render correctly:

    • the pattern has a width of 20x20
    • the rectangle inside the pattern extends past the pattern dimensions, e.g. from -1,-1 to 21,21
    • the rectangle inside the pattern uses shape-rendering "crispEdges"

    but I believe the result should be the same without any of them.

    Perhaps the pattern should be copied on all four sides while rendering its content?



    opened by or 10
Evgeniy Reizner
Evgeniy Reizner
A high-performance SVG renderer, powered by Rust based resvg and napi-rs.

resvg-js resvg-js is a high-performance SVG renderer, powered by Rust based resvg and napi-rs. Fast, safe and zero dependencies! No need for node-gyp

一丝 744 Jan 7, 2023
Sub-pixel precision light spot rendering library for astronomy and video tracking applications.

Planetarium Sub-pixel precision light spot rendering library for astronomy and video tracking applications. Example usage use planetarium::{Canvas, Sp

Sergey Kvachonok 5 Mar 27, 2022
Small, lightweight and fast library for rendering text with wgpu.

wgpu-text wgpu-text is a wrapper over glyph-brush for fast and easy text rendering in wgpu. This project was inspired by and is similar to wgpu_glyph,

Leon 20 Nov 30, 2022
Graph data structure library for Rust.

petgraph Graph data structure library. Supports Rust 1.41 and later. Please read the API documentation here Crate feature flags: graphmap (default) en

null 2k Jan 9, 2023
A graph library for Rust.

Gamma A graph library for Rust. Gamma provides primitives and traversals for working with graphs. It is based on ideas presented in A Minimal Graph AP

Metamolecular, LLC 122 Dec 29, 2022
Simple but powerful graph library for Rust

Graphlib Graphlib is a simple and powerful Rust graph library. This library attempts to provide a generic api for building, mutating and iterating ove

Purple Protocol 177 Nov 22, 2022
Library for Rubik's cube applications.

Rubik Master Do you like to solve Rubik's cube? I do. As a cuber and programmer, I want to build a toolset to build applications like S

Akira Hayakawa 12 Nov 3, 2022
The library provides basic functions to work with Graphviz dot lang from rust code.

Description The library provides the basic access to the graphs in graphviz format with ability to import into or export from it. Base examples: Parse

Boris 28 Dec 16, 2022
Rust library for of graph ensembles

Rust library for random graph ensembles Minimal Rust version: 1.55.0 Implements simple sampling and monte carlo (or rather markov-) steps, that can be

Yannick Feld 2 Dec 14, 2022
Generic framebuffer implementation in Rust for use with embedded-graphics library

Fraramebuffer implementation for Rust's Embedded-graphics Framebuffer approach helps to deal with display flickering when you update multiple parts of

Bernard Kobos 9 Nov 29, 2022
Python library for embedding large graphs in 2D space, using force-directed layouts.

Graph Force A python/rust library for embedding graphs in 2D space, using force-directed layouts. Installation pip install graph_force Usage The first

Niko Abeler 159 Dec 29, 2022
resvg is an SVG rendering library.

resvg can be used as a Rust library, a C library and as a CLI application to render SVG files based on a static SVG Full 1.1 subset.

Evgeniy Reizner 1.8k Dec 30, 2022
Let Tauri's transparent background rendering window be stacked on Bevy's rendering window in real time to run the game with native-level performance!

Native Bevy with Tauri HUD DEMO 将 Tauri 的透明背景渲染窗口实时叠在 Bevy 的渲染窗口上,以使用原生级别性能运行游戏! Let Tauri's transparent background rendering window be stacked on Bev

伊欧 3 Mar 25, 2024
A simple 2D plotting library that outputs graphs to SVG that can be styled using CSS.

Poloto graphs can be stylized using css either directly in the SVG, or from inside of html with an embedded svg. The latter allows the user to dynamically match the svg to their website's theme.

Ken Reed 119 Dec 13, 2022
A simple Node.js library to convert raster images into svg

@neplex/vectorizer A simple Node.js library to convert raster images into svg using VTracer, with time complexity of O(n). Installation npm install @n

Neplex 21 Dec 28, 2023
svgcleaner could help you to clean up your SVG files from the unnecessary data.

svgcleaner svgcleaner helps you clean up your SVG files, keeping them free from unnecessary data. Table of Contents Purpose Goals Alternatives Charts

Evgeniy Reizner 1.5k Jan 9, 2023
🔭 Annict での今期の視聴状況を SVG 画像として出力するサーバ (WIP)

annict-profile-card ?? Annict の視聴状況などを SVG 画像として出力する API サーバ (WIP) Annict GraphQL API を使用しています。

Nep 16 Dec 20, 2022
An SVG toolkit based on resvg

rusty-svg An SVG toolkit based on resvg This module is compiled to WASM and currently only supports Node.js Comparing with the backend ReSVG, this mod

Zimon Dai 9 Mar 21, 2022
Convert your ascii diagram scribbles into happy little SVG

Svgbob Svgbob can create a nice graphical representation of your text diagrams. Svgbob provides a cli which takes text as an input and creates an svg

Jovansonlee Cesar 3.4k Dec 25, 2022
The tool to make svg with triangles by length from two points.

The tool to make svg with triangles by length from two points.

null 2 Sep 27, 2021