I have a simple test SVG that uses two installed typefaces (Helvetica-Narrow
and Helvetica-Bold
):
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="50">
<text x="0" y="24" fill="blue" font-family="Helvetica-Bold" font-size="24px">Bold</text>
<text x="0" y="48" fill="blue" font-family="Helvetica-Narrow" font-size="24px">Narrow</text>
</svg>
If I convert this to a PDF file using ImageMagick (ImageMagick 7.0.2-0 Q16 x86_64 running on CentOS Linux 7 (Core)), then the result does not use the installed fonts.
For example:
$ convert -density 600 test.svg test.pdf
Yields:
It looks like ImageMagick defaults to using the normal weight of Helvetica
, which does not match either of the font families specified in the input SVG.
Next, I try specifying the path to one of the typefaces specified in the input SVG. This is a path to the Helvetica-Bold
typeface, as determined from running convert -list font
.
$ convert -density 600 -font /net/module/sw/ghostscript-fonts/5.50-32/n019004l.pfb test-helvetica-mix.svg test-helvetica-mix-bold.pdf
The first <text>
element is correct — it uses Helvetica-Bold
. The second <text>
element is incorrect - it also uses Helvetica-Bold
, but should really be using Helvetica-Narrow
.
Still, I'm getting closer with this approach, so I try adding the path to the second typeface used in the input SVG:
$ convert -density 600 -font /net/module/sw/ghostscript-fonts/5.50-32/n019004l.pfb -font /net/module/sw/ghostscript-fonts/5.50-32/n019043l.pfb test-helvetica-mix.svg test-helvetica-mix-both.pdf
ImageMagick uses the Helvetica-Narrow
typeface for both elements, which is incorrect for the same reason.
Is there a way to convince ImageMagick to use the correct typefaces specified in the <text>
elements in the input SVG?