Converting SVG with custom fonts to PNG using ImageMagick

后端 未结 4 1805
误落风尘
误落风尘 2021-01-06 06:07

I\'m converting SVG\'s to PNG using ImageMagick and all works like a charm until I tried adding custom fonts using @font-face and then in the SVG file. In Batik this worked

4条回答
  •  执念已碎
    2021-01-06 06:18

    I once had a bunch of SVG files, one page per file (an entire book). The fonts were auto-generated, one for each page. The character encoding was non-standard, I believe that only the characters actually used in the page were put into the fonts. Even though the fonts were embedded using data-uris into the SVG, none of the programs I used (Imagemagick, Inkscape, rsvg-convert) could display them. Only Firefox was able to render the pages correctly. Here's what I did:

    First I created a simple HTML with all the pages:

    
        
             
             
    

    etc

    Then, I opened the HTML in Firefox. It took some time but it rendered the entire book.

    Then, I printed the entire page as PDF. I first set the print options to not print out headers/footers.

    The result was a large PDF of several megabytes (there were also raster images in there).

    Not the easiest solution, but it worked. It's a pity that none of the other SVG renderers are as good as the one in Firefox.

    Hope this helps someone.

提交回复
热议问题