DOMPDF不缓存某些字体

问题描述:

我想在我的PDF使用5级不同的字体(所有的TrueType字体)。昨天,我加入其中之一作为@font-face和文件复制到/storage/fonts(我用barryvdh/laravel-DOMPDF,所以这是默认设置)。 .ufm创建并添加到dompdf_font_family_cache.php,一切工作正常。DOMPDF不缓存某些字体

今天我想添加其余的字体,我已经制作了单独的@font-face属性,复制了字体但没有创建.ufm文件,所以它们不能在PDF中使用。

谷歌字体可以添加没有任何问题,他们得到缓存!

<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 25年6月5日),Laravel 5.3,DOMPDF 0.8W/laravel-DOMPDF上。

我错过了什么?

删除所有文件在storage\fonts

授予权限DOMPDF创建的字体有

sudo chmod -R 755 storage/fonts 

创建一个新的PDF再生的字体。

+1

好了,你把我在正确的轨道上。我删除了'/ storage/fonts'目录中的所有内容,将这些文件放在'public'目录中,并在'@ font-face'中调用这些URL。所有字体都被缓存并准备就绪,现在我明白它是如何工作的。 :) 谢谢您的帮助! – Ozwald

+0

没问题,很高兴帮助你! –