openSUSE / daps

DocBook Authoring and Publishing Suite (DAPS)
https://openSUSE.github.io/daps
Other
62 stars 19 forks source link

Should we replace inkscape with rsvg-convert? #654

Open tomschr opened 3 years ago

tomschr commented 3 years ago

Problem description

Some time ago we had some issues with Inkscape:

It seems we could replaces Inkscape with a more light-weight tool.

Idea

I got informed that Fedora had some problems with Inkscape too (see [1]). This was mainly for the dblatex tool, but it should be correct for daps as well. Originally, the bug was filed in [2], but it seems the Inkscape won't fix it. Fedora created a patch[3] because of this which basically replaces inkscape with rsvg-convert.

We need to check if:

References

  1. https://sourceforge.net/p/dblatex/feature-requests/21/
  2. https://gitlab.com/inkscape/inkscape/-/issues/1342
  3. https://src.fedoraproject.org/rpms/dblatex/raw/rawhide/f/dblatex-0.3.11-replace-inkscape-by-rsvg.patch
  4. https://build.opensuse.org/request/show/921890
ghost commented 3 years ago

Using rsvg instead of Inkscape will bring rather predictable conversion issues, especially (but not limited to) when graphics have been originally created with Inkscape, e.g. when they use the flowRoot text element.

You are right that Inkscape is huge and drags in a lot more dependencies than we want though.

tomschr commented 3 years ago

We've discussed this topic during our sync call. Probably we will have issues with the svg:flowRoot tag which is likely to be unsupported by rsvg-convert.

I've tried to create a test but was unable to find a svg:flowRoot tag in my SVG with Inkscape 1.0.2. Digging a bit deeper, I found this:

»The SVG 1.2 Full specification was never completed (as you can see from the link it's still in draft from 2005) and only Inkscape ever supported flowRoot I think. I don't think it's intended that flowRoot will be part of SVG 2 either as that is likely to implement flowing text with a different and more CSS compatible mechanism so flowRoot is best avoided.« Source: https://stackoverflow.com/a/19391378

which seem to explain why it doesn't appear anymore. I can also save my SVG in Inkscape as version 1.1, not as 1.2. I'm pretty sure this flowRoot was available in the pre 1.0 version.

I've also looked into our images/srv/svg and haven't found any occurances of flowRoot (as it was to be expected). Sooo... to make a long story short, maybe this flowRoot isn't a big deal anymore. For SVG images which are created by other tools, you can convert the flow text into some static presentation (use main menu "Text > Unflow" or "Text > Convert to Text").

However, we may still have other conversion issues when using rsvg-convert. To clarify which elements and attributes are actually supported, I've created issue 801 in the upstream project. Let's see if they find it useful.

Maybe we need to compare if there are any differences between the Inkscape generated PNGs and the rsvg-convert generated ones. After then we can decide if this is going to fly or not.

tomschr commented 3 years ago

I've investigated a little bit further and wrote a small (dirty) Shell script that you can run on any cloned repo. It a) converts each SVG to PNG with rsvg-convert and inkscape and b) compares the result of the two PNGs with compare (ImageMagick).

Shell script to convert and compare SVGs ```bash #!/bin/bash BASEDIR=/tmp/svgcompare LIBRSVG=$BASEDIR/librsvg INKSCAPE=$BASEDIR/inkscape DIFFS=$BASEDIR/diffs mkdir -p $LIBRSVG $INKSCAPE $DIFFS for i in images/src/svg/*.svg; do base=${i##*/} base=${base%%.svg} format=png echo "## Converting $i..." rsvg-convert --format=$format --width=800 --height=600 \ --background-color=white $i > $LIBRSVG/$base.$format inkscape --export-type=$format \ --export-width=800 --export-height=600 \ --export-background=white \ -o $INKSCAPE/$base.$format \ $i echo "## Calculating difference for $i..." # from https://askubuntu.com/a/209548 using Imagemagick compare -compose src $INKSCAPE/$base.$format \ $LIBRSVG/$base.$format \ $DIFFS/$base.$format done ```

My findings so far:

ghost commented 3 years ago

(use main menu "Text > Unflow"

Aah, good to know! I never knew this tool existed!

In the past, Inkscape created flowRoots when dragging open a bounding box first rather than just clicking and then typing. However, I just tried it on Inkscape 1.0.1 (the version that ships in Leap 15.3) and, you're right, it does not create flowRoots in either case! Progress! Awesome.

tomschr commented 3 years ago

After some further tests, the xmlgraphics-batik-rasterizer script makes the best output from what I can see. It's based on Batik, a SVG library which supports a lot of features.

If we really want to move away from Inkscape, it could be an alternative. However, it's Java, so it's not as fast as Inkscape or rsvg-convert. :disappointed:

ghost commented 3 years ago

However, we probably already need the Batik rasterizer because we use FOP. So, speed and java-ness aside, if Batik is a good implementation of SVG and runs reliably, then using that as broadly as possible sounds like a good idea. (edit We have our troubles with FOP... and switching away from FOP has been on my mind more than once. That might play into this decision too.)

I just checked how the Dia pipeline works and it seems that is already independent from Inkscape -- DAPS currently allows DIA->PNG and DIA->SVG but both only use the dia command, e.g.

DIA->PNG -- make/images.mk:448:

    LANG=C dia -t png --export=$@ $< $(DEVNULL) $(ERR_DEVNULL)

Analogously on l. 520 for DIA->SVG.

lkocman commented 3 weeks ago

I will work on this one. This is the only reason why SLFO:Main:Build has curently inkscape. And it's ridiculous that SLES with almost no desktop has inkscape in it. Once the dependency from daps is gone, we can keep inkscape simply in Leap and offer it to sles via PACKAGEHUB. Thx