neocotic / convert-svg

Node.js packages for converting SVG into other formats using headless Chromium
MIT License
197 stars 45 forks source link

Fonts are not applied in resulting PNG #70

Open Sashkan opened 4 years ago

Sashkan commented 4 years ago

I'm using this lib to convert an SVG string to a PNG. My SVG includes a google font, which is imported in its style tag.

On the SVG, the font is properly applied. Unfortunately, after using the convert method, it gets back to standard browser font.

Is there anything to add to keep styling in place ?

Here's my piece of code for converting:

        // get my SVG
        .then((html) => {
          return html.toString()
        })
        .then(htmlString => convert(htmlString))
        .then((productText) => {
          res.set('Content-Type', 'image/png');
          res.send(productText);
        })
neocotic commented 2 years ago

I'm sorry for the incredibly long delay in replying in responding to you but life sometimes gets in the way of OSS development. I thank you for your patience and wonder if you could please provide a reproducible SVG along with actual output. Also, a complete code sample would go along way to helping me investigate further.

nick-keller commented 2 months ago

To embed a Google font in your SVG:

<svg>
  <defs>
    <style type="text/css">@import url(http://fonts.googleapis.com/css?family=Inter);</style>
  </defs>
  ...
</svg>