svgdpilibrsvg

How to get rsvg to assume 96 dpi for SVG?


When I use

rsvg-convert.exe -f pdf -o <output-name>.pdf <input-name>.svg

I get a result that differs from how the SVG is rendered in Inkscape and Firefox.

This is a simple test SVG:

<svg width="150" height="100" xmlns="http://www.w3.org/2000/svg">
  <text y="50" font-size="12" fill="black">Test</text>
  <text x="50" y="50" font-size="12pt" fill="black">Test</text>
  <text x="100" y="50" font-size="16px" fill="black">Test</text>
</svg>

In Inkscape and Firefox the middel and right text have the exact same size since these applications seem to assume that 1pt = 1.333333px which is the CSS recommendation. However, rsvg seems to assume 1pt = 1.25px which leads to different sizes of the texts. How can I get rsvg to output it correctly (as Inkscape and Firefox).

I tried the options -p and -d with 96 but that didn't give the correct result either.


Solution

  • Setting the dpi works here with rsvg-convert 2.40.20:

    rsvg-convert -f pdf --dpi-x=96 --dpi-y=96 -o <output-name>.pdf <input-name>.svg
    

    I also confirmed setting the output format to svg (text will be converted to paths) and comparing the height in Inkscape.