2013-07-12 149 views
0

我正在一個webfonts服務器上工作,我得到了API吐出正確的MIME類型的CSS。他們也被鏈接到頁面。爲什麼我的字體文件沒有下載未加載?

@font-face { 
    font-family: 'Pagul'; 
    src: url('http://localhost:5000/api/webfonts/static/Pagul.eot'); 
    src: local('☺'), url('http://localhost:5000/api/webfonts/static/Pagul.woff') format('woff'), 
     url('http://localhost:5000/api/webfonts/static/Pagul.ttf') format('truetype'), 
    font-weight: normal; 
    font-style: normal; 
} 

的TTF,EOT文件可以manualy使用的鏈接下載的,由於某種原因,這些字體 不是我究竟錯在這裏做瀏覽器加載?字體文件沒有適當的mimetypes是這個問題?

我也試過font-squirells語法,它不工作。 PS:Css是動態生成並添加到頭部?

+0

'localhost'?開發者控制檯中是否有任何控制檯錯誤? – Raptor

+0

沒有控制檯錯誤。 – Diadara

回答

0

使用相對路徑而不是絕對值。例如,如果你的CSS是在網站/ CSS/style.css文件,你的字體是在網站/ API /網絡字體/靜態/目錄:

@font-face { 
    font-family: Pagul; 
    src: url('../api/webfonts/static/Pagul.eot'); 
    src: url('../api/webfonts/static/Pagul.woff') format('woff'), 
    url('../api/webfonts/static/Pagul.ttf') format('truetype'), 
    font-weight: normal; 
    font-style: normal; 
} 

另外,使用像谷歌的字體服務,要麼他們的鏈接您的HTML上的CSS或直接導入到您的CSS

+0

不能這樣做,我正在嘗試使谷歌字體,所以沒有相對路徑。 – Diadara

+0

對不起,在這種情況下,我誤解了你的問題 – mikedugan

相關問題