2017-03-16 59 views
0

我想在我的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上。

我錯過了什麼?

回答

0

刪除所有文件在storage\fonts

授予權限DOMPDF創建的字體有

sudo chmod -R 755 storage/fonts 

創建一個新的PDF再生的字體。

+1

好了,你把我在正確的軌道上。我刪除了'/ storage/fonts'目錄中的所有內容,將這些文件放在'public'目錄中,並在'@ font-face'中調用這些URL。所有字體都被緩存並準備就緒,現在我明白它是如何工作的。 :) 謝謝您的幫助! – Ozwald

+0

沒問題,很高興幫助你! –