Issues with export fidelity of SVG diagrams in Archi Ubuntu and Windows

Started by raimondb, January 08, 2025, 07:26:00 AM

Previous topic - Next topic

raimondb

Hi,

I am running jArchi scripts to export diagrams to SVG. However, when I run it on Windows from the tool, there is differences compared to running it from the Ubuntu image as part of CI.

I noticed that one thing was that I need to copy the ArchiColours.prefs to the Archi\.metadata\.plugins\org.eclipse.core.runtime\.settings dir as com.archimatetool.editor.prefs so that all default colors will match up with my custom setting.

But I also notice that with the windows export, text labels are nicely fitting the elements, while exporting from Ubuntu they are slightly larger and therefore spreading across two lines leading to it not fitting inside the element boundaries anymore.

What other settings/preferences to I need to replicate as well to ensure the picture will look exactly the same when exporting?

Phil Beauvoir

Hi, export to SVG is never perfect depending on a number of factors including OS and font size. This is more often the case on Linux and certainly fonts on that OS differ than those on Windows.

Take a look here:

https://github.com/archimatetool/archi-scripting-plugin/wiki/Model-Functions#renderViewToSVG

One setting you might need on Linux is textOffsetWorkaround set to true.
If you value and use Archi, please consider making a donation.
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

raimondb

Hi Phil,

Indeed in the mean time I found out the font was causing the issue since I did not have Segoe UI available in Linux, so I installed it, and that mostly fixed the issue  8) .

However I did notice the margin was a bit smaller, so instead of font size 18, I went with size 16 to make it fit the element box clean on both Windows and Linux.

Regarding the method you linked, it is unclear to me how the setViewBox is supposed to work, it seems to take some default, but does not work for big diagrams. I ended up to add some jArchi scripting to calculate the viewbox based on mix/max x/y of all the boxes on the diagram and specify the viewBoxBounds myself.

Further, what is the kind of workaround that the textOffsetWorkaround is doing exactly?

Also I was wondering about the textAsShapes and Embedfonts. I am now using textAsShapes = true and EmbedFonts = false. But since I now installed the font, would it also work on all/most target platforms to have textAsShapes=false and EmbedFonts=true? Since my diagrams are now 2.6MB instead of around 330kb :-)

Phil Beauvoir

Quote from: raimondb on January 10, 2025, 11:12:53 AMFurther, what is the kind of workaround that the textOffsetWorkaround is doing exactly?

It reduces the font height by 1 point, so a slightly smaller font should fit better.

Quote from: raimondb on January 10, 2025, 11:12:53 AMAlso I was wondering about the textAsShapes and Embedfonts. I am now using textAsShapes = true and EmbedFonts = false. But since I now installed the font, would it also work on all/most target platforms to have textAsShapes=false and EmbedFonts=true? Since my diagrams are now 2.6MB instead of around 330kb

I don't know. You'll have to experiment.

A general point on export to SVG/PDF. The code to do this is taken from an Eclipse project (see here). It has never been perfect and we've tried to workaround several issues with it. We have to live with its foibles (unless someone wants to take a look at it and contribute patches).
If you value and use Archi, please consider making a donation.
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.