【发布时间】:2017-03-16 11:17:50
【问题描述】:
我想在我的 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 上。
我错过了什么?
【问题讨论】: