2012-06-25 87 views
-2

我試圖使用這種字體:http://www.fontsquirrel.com/fontfacedemo/eb-garamond 因此,我下載了類型工具包並將其放置在正確的目錄中。@font not working from fontsquirrel

CSS

@font-face {

font-family: 'EBGaramondSC'; 
src: url('/EBGaramondSC-webfont.eot'); 
src: url('/EBGaramondSC-webfont.eot?#iefix') format('embedded-opentype'), 
    url('/EBGaramondSC-webfont.woff') format('woff'), 
    url('/EBGaramondSC-webfont.ttf') format('truetype'), 
    url('/EBGaramondSC-webfont.svg#EBGaramondRegular') format('svg'); 
font-weight: normal; 
font-style: normal; 
} 

p.style2 {font: 18px/27px 'EBGaramondSC', Arial, sans-serif;} 

HTML [p class="style2"] Alfab Solutions, LLC is a custom security firm who focuses on rural secruity solutions. We offer rugged, secure camera systems which integrate into our SSL encrypted website. We provide 24/7 access to your security footage, so you can have peace of mind that your assets are safe. [/p] Ignore brackets

螢火蟲甚至不顯示正確的字體圖像。是什麼賦予了?
我有一個奇怪的目錄結構。索引是.php,它是從模板文件生成的。所以我的字體在模板目錄中,因爲它們隻影響那裏的html。

回答

6

如果你看一下CSS代碼,你會發現URL都是絕對路徑(你瞭解相對和絕對路徑,如果沒有,閱讀它們:?d)

@font-face { 
    src: url('/EBGaramondSC-webfont.eot'); 
} 

注意的/

它應該是:

src: url('/templates/EBGaramondSC-webfont.eot'); 

或者,如果字體文件是在同一文件夾中的CSS:

src: url('EBGaramondSC-webfont.eot'); 

打開Chrome檢查(即輸出404個警告)告訴我, :

未能加載資源:服務器用的404 一個狀態響應(未找到)http://www.alfabsolutions.com/EBGaramondSC-webfont.svg

所以是的,那!祝你好運。

+0

看起來像這樣做。我對Chrome Inspector並不熟悉,但我會看看它。 Firebug沒有向我顯示警告。自從該目錄提供模板以來,我想到了字體也需要在那裏。感謝您解決它。 – Meretrix

1

看着你的網站和代碼,它試圖從/加載字體。嘗試將@ font-face聲明中的路徑更改爲/ template/*並查看它是否有效。

問候, 拉吉

0

你只需要改變你的CSS文件,style.css,使得src屬性指向每個字體文件的正確路徑:

錯誤

src: url('/EBGaramondSC-webfont.eot'); 

已更正

src: url('/templates/EBGaramondSC-webfont.eot');