我正在运行html-pdf以使用phantomJS通过nodejs生成PDF并在aws lambda上运行它。我有自定义字体,并在其中引用了路径css (src: url('path/fonts.ttf');
使pdf呈现为一个大图像,并且文件大小比原始文件大10倍。
所以我将其更改为在本地引用字体,以解决将qt_qpa_fontdir
和home
变量更改为本地字体目录的文件大小问题,并且可以工作。现在显示字体,文件大小恢复正常。但是,字体的字母间距/字距不正确。
当我通过路径引用字体时,这也是一个问题,但我使用xml通过共享字体文件夹中的fonts.conf文件修复了该问题:
<?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>
该修补程序无济于事,因为字体是在本地引用的。我是否还必须指定QT字体配置文件路径?或更改fonts.conf?
您是否找到此问题的任何可行解决方案,也面临相同的字体间距错误。