DOMPDF 不缓存某些字体
DOMPDF not caching some fonts
我想在我的 PDF 中使用 5 种不同的字体(都是 TrueType)。昨天我将其中一个添加为@font-face
并将文件复制到/storage/fonts
(我使用的是barryvdh/laravel-dompdf,所以这是默认设置)。 .ufm 已创建并添加到 dompdf_font_family_cache.php
,一切正常。
今天我想添加其余的字体,我制作了单独的 @font-face
属性,复制了字体但没有创建 .ufm 文件,因此它们不能在 PDF 中使用。
Google 字体 可以毫无问题地添加,并且它们正在被缓存!
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
@page {
margin:0;
padding:0;
}
@font-face {
font-family: 'font1';
src: url('/storage/fonts/font1.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'font2';
src: url('/storage/fonts/font2.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
.font1{
text-align: center;
font-family: 'font1', sans-serif;
}
.font2{
font-family: 'font2', sans-serif;
text-align: center;
}
</style>
</head>
<body>
<div id="container">
<div class="font1">This font is cached</div>
<div class="font2">This font isn't</div>
</div>
</body>
</html>
我在本地 WAMP 服务器上 (PHP 5.6.25),Laravel 5.3,DOMPDF 0.8 w/ laravel-dompdf。
我错过了什么?
删除storage\fonts
中的所有文件
允许 DOMPDF 在那里创建字体
sudo chmod -R 755 storage/fonts
创建一个新的 pdf 以重新生成字体。
我想在我的 PDF 中使用 5 种不同的字体(都是 TrueType)。昨天我将其中一个添加为@font-face
并将文件复制到/storage/fonts
(我使用的是barryvdh/laravel-dompdf,所以这是默认设置)。 .ufm 已创建并添加到 dompdf_font_family_cache.php
,一切正常。
今天我想添加其余的字体,我制作了单独的 @font-face
属性,复制了字体但没有创建 .ufm 文件,因此它们不能在 PDF 中使用。
Google 字体 可以毫无问题地添加,并且它们正在被缓存!
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
@page {
margin:0;
padding:0;
}
@font-face {
font-family: 'font1';
src: url('/storage/fonts/font1.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'font2';
src: url('/storage/fonts/font2.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
.font1{
text-align: center;
font-family: 'font1', sans-serif;
}
.font2{
font-family: 'font2', sans-serif;
text-align: center;
}
</style>
</head>
<body>
<div id="container">
<div class="font1">This font is cached</div>
<div class="font2">This font isn't</div>
</div>
</body>
</html>
我在本地 WAMP 服务器上 (PHP 5.6.25),Laravel 5.3,DOMPDF 0.8 w/ laravel-dompdf。
我错过了什么?
删除storage\fonts
允许 DOMPDF 在那里创建字体
sudo chmod -R 755 storage/fonts
创建一个新的 pdf 以重新生成字体。