Home > Software engineering >  Using Sharp to turn svg to png corrupts text in node.js
Using Sharp to turn svg to png corrupts text in node.js

Time:10-21

I am using sharp to convert an svg file into png format to upload to a slack workspace.

I found the same issue enter image description here

CodePudding user response:

After browsing several Github Issues about this [Link 1, Link 2 , Link 3] , I did more research and discovered that I needed a font-config file and fonts downloaded because the Replit server did not have the fonts installed.

File Structure


    - index.js
    - api
     - fetch.js
    - fonts
     - fonts.conf
     - SourceSansPro-Regular.ttf

fonts.conf


     <?xml version="1.0"?>
     <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
     <fontconfig>
     <dir>/home/runner/gittrack/fonts</dir>
     <config></config>
     </fontconfig>

Once I added the above changes, I am now getting fonts on my png

  • Related