I am running html-pdf to generate a PDF via nodejs using phantomJS and running it on aws lambda.
I have custom fonts, and referencing them with path in
css (src: url('path/fonts.ttf');
was causing the pdf to render as one large image and the filesize was 10x larger than the original.
so I changed it to reference the fonts locally, to fix the filesize issue changing qt_qpa_fontdir
and home
variable to my local fonts directory and it works. the fonts now display and the filesize is back to normal.
However, there is bad letter spacing/kerning with the fonts.
this was also a problem when I was referencing the fonts via a path but I fixed that with a fonts.conf file in the shared fonts folder using an xml:
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<match target="font">
<edit mode="assign" name="rgba">
<const>rgb</const>
</edit>
</match>
<match target="font">
<edit mode="assign" name="hinting">
<bool>true</bool>
</edit>
</match>
<match target="font">
<edit mode="assign" name="hintstyle">
<const>hintslight</const>
</edit>
</match>
<match target="font">
<edit mode="assign" name="antialias">
<bool>true</bool>
</edit>
</match>
<match target="font">
<edit mode="assign" name="lcdfilter">
<const>lcddefault</const>
</edit>
</match>
</fontconfig>
That fix is not helping now that the fonts are being referenced locally. Do I have to specify the QT fonts config file path as well? or change the fonts.conf?