sharp
sharp copied to clipboard
Fonts are not rendered correctly when using an svg
Question about an existing feature
What are you trying to achieve?
Render an svg with the fonts
The fonts are not on the host os (end user can upload fonts) but I am downloading all of ti to a temp folder and setting the env for font config
When you searched for similar issues, what did you find that might be related?
I saw that I need to provide the FONTCONFIG_PATH
and the first line in my code is this
process.env.FONTCONFIG_PATH = TEMP_FILES_FONTS
The svgs are rendering correctly but the font is using the default font, I am using the fontname
library to extract the name from the fonts
Use the FC_DEBUG
environment variable to help debug font discovery.
https://sharp.pixelplumbing.com/install#fonts https://www.freedesktop.org/software/fontconfig/fontconfig-user.html
@lovell adding FC_DEBUG
doesn't output anything, here is my script
process.env.FONTCONFIG_PATH = TEMP_FILES_FONTS;
process.env.FC_DEBUG = '1';
this is at the top of the file
Make sure these are set before require('sharp')
is called, and ideally before the process starts.
I have set it before importing sharp and also did the following
- added
FC_DEBUG = 1
to my.env
file - added this to the
dev
script,export FC_DEBUG=1 && vite dev
still no logs
Is the FC_CONFIG supposed to be a directory with fonts or a fontconfig file with entries for each font? If the latter can I set whatever family names I want for fonts? That was another pain point
FONTCONFIG_PATH
is an absolute path, without the trailing slash, to a directory containing a custom fonts.conf
file.
@isaacfink Were you able to make any progress with this?
Closing due to inactivity but please feel free to reopen with more details if further help is required.