DOMPDF如何包含自定义字体 我将dompdf库的文件夹复制到了/dompdf 内置Roboto-Black.ttf的/font文件夹 我创建了一个php文件index.php

DOMPDF如何包含自定义字体 我将dompdf库的文件夹复制到了/dompdf 内置Roboto-Black.ttf的/font文件夹 我创建了一个php文件index.php,php,css,dompdf,Php,Css,Dompdf,谢谢!解决方案是在my index.php中添加tmp目录 // Instantiate and use the dompdf class $dompdf = new Dompdf(array('tempDir'=>'/srv/www/xyz/tmp')); 就这些。现在所有常规自定义字体都可以使用了 如果对url使用完整路径,如url('s),会发生什么http://mysite/fonts/Roboto-Black.ttf)?我也试过这个->空白屏幕!路径是正确的,因为只有这样它才

谢谢!解决方案是在my index.php中添加tmp目录

// Instantiate and use the dompdf class 
$dompdf = new Dompdf(array('tempDir'=>'/srv/www/xyz/tmp'));

就这些。现在所有常规自定义字体都可以使用了

如果对url使用完整路径,如
url('s),会发生什么http://mysite/fonts/Roboto-Black.ttf)
?我也试过这个->空白屏幕!路径是正确的,因为只有这样它才会显示不正确。可能是由于php设置或自定义字体的dompdf设置?如果有人尝试了完全相同的文件,这会很有趣,如果可以的话这里有更多信息,您可以测试:
<style>
    .customfont {
        color: #35aa45;
    }
</style>

<div class="customfont">
    this is my text
</div>
<style>
    @font-face {
        font-family: 'Roboto';
        src: url('fonts/Roboto-Black.ttf') format('truetype');
    }

    .customfont {
        font-family: 'Roboto';
        color: #35aa45;
    }
</style>

<div class="customfont">
    this is my text
</div>
// Instantiate and use the dompdf class 
$dompdf = new Dompdf(array('tempDir'=>'/srv/www/xyz/tmp'));