stathissideris / ditaa

ditaa is a small command-line utility that can convert diagrams drawn using ascii art ('drawings' that contain characters that resemble lines like | / - ), into proper bitmap graphics.
GNU Lesser General Public License v3.0
924 stars 87 forks source link

What determines the SVG font size? Different machines produce different results. #72

Open hugobuddel opened 2 years ago

hugobuddel commented 2 years ago

What determines the font size that is used when generating SVG figures?

We create some documentation, like class diagrams, going from classes to ditaa to SVG to tikz (a LaTeX figure). Most text in the SVG figures has font size 15, however, some text has size 14 or 13. The figures are mostly text in boxes, and it is roughly the case that a smaller font size is selected in order to fit text in the box (text with many Ms and Ws often has a smaller font size than text with many Is). The main problem for us is that different machines produce different results. Which means that currently we can only consistently create figures on one particular machine.

I've not yet been able to determine what influences the font size being used. As in, I tried to create a Docker container that matches the other machine as closely as I could, but it still produces different results, so I'm probably missing something.

Attached differentsizes.zip with a ditaa file and two svg files (apparently these cannot be uploaded to github directly). The diff (machine1 is the main machine, machine2 a docker container, both Ubuntu 20.04):

diff ApplyAstrom.machine1.svg ApplyAstrom.machine2.svg 
24,27c24,27
<     <text x='40' y='166' font-family='Courier' font-size='13' stroke='none' fill='#ffffff' ><![CDATA[ASTROM_HDR]]></text>
<     <text x='280' y='68' font-family='Courier' font-size='15' stroke='none' fill='#ffffff' ><![CDATA[DETRENDFINALAI_IMG or]]></text>
<     <text x='280' y='82' font-family='Courier' font-size='14' stroke='none' fill='#ffffff' ><![CDATA[DETRENDFINAL_IMG]]></text>
<     <text x='335' y='250' font-family='Courier' font-size='15' stroke='none' fill='#ffffff' ><![CDATA[apply_astrom]]></text>
---
>     <text x='41' y='166' font-family='Courier' font-size='14' stroke='none' fill='#ffffff' ><![CDATA[ASTROM_HDR]]></text>
>     <text x='280' y='69' font-family='Courier' font-size='15' stroke='none' fill='#ffffff' ><![CDATA[DETRENDFINALAI_IMG or]]></text>
>     <text x='280' y='83' font-family='Courier' font-size='15' stroke='none' fill='#ffffff' ><![CDATA[DETRENDFINAL_IMG]]></text>
>     <text x='341' y='251' font-family='Courier' font-size='15' stroke='none' fill='#ffffff' ><![CDATA[apply_astrom]]></text>

Both files are created through

java -jar ditaa-0.11.0-standalone.jar "ApplyAstrom.ditaa" -E --no-shadows --svg "ApplyAstrom.svg"

My guess is that it has something to do with the exact font that is being used. But I don't understand what font exactly is chosen or how. So maybe the font size can be made consistent by using --svg-font-url, but I don't understand how to use that either.