manpagez: man pages & more
html files: rsvg-2.0
Home | html | info | man

Recommendations for applications with SVG assets

Before librsvg 2.46, applications would normally load an SVG asset, then they would query librsvg for the SVG's size, and then they would compute the dimensions of their user interface based on the SVG's size.

With librsvg 2.46 and later, applications may have an easier time by letting the UI choose whatever size it wants, or by hardcoding a size for SVG assets, and then asking librsvg to render SVG assets at that particular size. Applications can use rsvg_handle_render_document, which takes a destination viewport, to do this in a single step.

To extract individual elements from an SVG document and render them in arbitrary locations — for example, to extract a single icon from a document full of icons —, applications can use rsvg_handle_render_element.

Injecting a user stylesheet

It is sometimes convenient for applications to inject an extra stylesheet while rendering an SVG document. You can do this with rsvg_handle_set_stylesheet. During the CSS cascade, the specified stylesheet will be used with a "User" origin.

© 2000-2022
Individual documents may contain additional copyright information.