Skip to content

(#907): Don't go through gdk-pixbuf when an image element references an SVG document

Federico Mena Quintero requested to merge federico/librsvg:image-svg-907 into main

From the days when librsvg was written in C, its implementation of the <image> element always used gdk-pixbuf to load images, even when embedding an external SVG like <image href="nested.svg"/>. This more or less works; gdk-pixbuf calls the io-svg loader, which in turn calls librsvg to rasterize the document. However, it does not pay attention to the preserveAspectRatio attribute in the <image> properly, and is of course an unnecessary layer of indirection.

This MR does the following:

  • Consolidates the externs and images fields in struct Document into a single Resource enum, which can be a raster image or an SVG document.
  • Moves some functions around so the internal render_document can be called without going through the public API.
  • Adds coords-viewattr-04-f.svg from the SVG1.1 test suite.
  • Call librsvg's internals directly to render that <image href="nested.svg"/> instead of going through gdk-pixbuf.
  • Implement handling of preserveAspectRatio in the containing <image>.

Fixes #907 (closed)

Merge request reports