rsvg-zoompan

What it is

rsvg-zoompan is a fork of (a few years old version, 2.40.16) of librsvg. It provides a single executable, rsvg-show, which can load and display an svg file on a gtk3 GUI, allows zooming and panning (with scroll wheel and mouse motion), and implements single key quick file reload.

Download, dependencies, how to compile

You can download a source release tarball or check out the most recent version from svn at svn://svn.repo.hu/rsvg-zoompan/trunk; if you have any problem or question, feel free to contact me.

Once you have the source, please follow the instructions in the README.

Dependencies: the usual set required by librsvg 2.40.16. Most notably:

Howto

Once you have the executable, copy it to /usr/bin then run from a shell; typical invocation examples:

rsvg-show /path/to/foo.svg
rsvg-show foo.svg
foo.sh | rsvg-show /dev/stdin

GUI control:

Note: it will pan only if you zoom in enough so any portion of the image is off-window.

Motivation

I am developing a topological autorouter for printed circuit boards. It has some real complicated geometry related parts where I need to visualize round cap arcs and lines on debug images. I am a console guy, doing all development on a text screen (not on X). What works for me is generating a debug image and looking at it when I need to - which is often only every 20th code modification.

For this task, round cap lines/arcs of variable width and color, I decided svg is a suitable format. What I didn't foresee is that there was no usable svg viewer out there.

My requirements are:

I was shocked to see how majority of the svg viewers, including web2.0 browsers, failed to pan and often even to zoom. Many dedicated svg viewers fail on one of these too. Some simply render the input svg into a pixmap and then works as a bmp viewer: you can zoom in to 800%, but all you see is the same as what you already saw at 100%, just with larger pixels. Inkscape can zoom and pan but there's no single-click reload, only the revert menu; and that messes up zoom/pan and even resizes the application window! Inkview doesn't zoom or pan - why would it do those when it is a dedicated viewer for a format whose first name is Scalable.

I am not a fool to sit down and write an svg loader/renderer from scratch, svg is way out of hands for that. So I looked at a few options, existing software I could fork and fix up.

I looked at inkscape's inkview first. Unfortunately it escalates very quickly into a huge pile of hard to follow C++ OOP class wizardy.

The second thing I checked was librsvg's test viewer. It is implemented in C and it already had zoom and pan. So I forked librsvg as rsvg-zoompan, renamed the test program to rsvg-show and modified it to do what I need. The only trick was that I had to fork an older version, to avoid depending on rust and 41 megabytes of crates.