Skip to content

WIP: Rustify rsvg-convert

Sven Neumann requested to merge svenfoo/librsvg:rustify-rsvg-convert into master

This is an attempt at #534 (closed).

So far there's command-line handling using the clap crate and a first attempt at doing the actual rendering. This is far from complete, there's a lot of loose ends, in particular determining the document size and viewport.

However I already ran into problems that I do not seem to be able to solve on my own. In order to create multi-page PDF files from a series of SVG files, I will have to create several instances of cairo::PdfSurface writing to the same stream. There will always only be a single instance alive at any point, however the cairo::PdfSurface API seems to require static lifetime for the stream and I haven't found a way to persuade the compiler to accept that the pointer to the stream is sound. I'd appreciate some hints on how this could be solved.

Update

Managed to make it compile and it actually seems to work, at least to the extent that I tested so far. The code still somehow looks seems to be more complex than it should be.

Update 2

Figured out now that I am overcomplicating things needlessly. I just got lost in the spaghetti that is rsvg-convert.c and didn't realize that I shouldn't create a new surface for each input file. Will close the pull request for now and rework the code.

Edited by Sven Neumann

Merge request reports