這是一個非常令人沮喪的錯誤!字體間歇性加載失敗?
我使用的是Font Awesome(本地託管)和一些其他字體,並且它們間歇性地無法加載 - 不是404,只是完全無法顯示在開發人員工具的網絡選項卡中,並且未在頁面上呈現。
它似乎最經常發生的第一次頁面加載 - 刷新字體然後加載/渲染確定。但是,清除瀏覽器緩存並不能可靠地重現問題。
我知道路徑正常,因爲字體在80%的時間內渲染OK。這是一個間歇性問題。我在OSX上使用Chrome v26。
我的CSS是這樣的:
<head>
...
<link rel="stylesheet" type="text/css" href="${context}/resources/font/opensans.css" />
<link rel="stylesheet" type="text/css" href="${context}/resources/css/font-awesome.min.css" />
...
而CSS文件看起來是這樣的:
@font-face {
font-family: 'open_sanslight';
src: url('opensans-light-webfont.eot');
src: url('opensans-light-webfont.eot?#iefix') format('embedded-opentype'),
url('opensans-light-webfont.woff') format('woff'),
url('opensans-light-webfont.ttf') format('truetype'),
url('opensans-light-webfont.svg#open_sanslight') format('svg');
font-weight: normal;
font-style: normal;
}
再次,路徑是正確的(用事實證明大約80%的時間字體確實呈現正確)。
可能會發生什麼?
你檢查網絡標籤@ firefox?是一樣的嗎? – 2013-04-05 10:43:12
我沒有注意到Firefox中的問題,現在我無法重現它(我實際上在Firefox中禁用了緩存,所以它應該更糟糕,如果有的話)。就像我說的那樣:阻擋。 – Richard 2013-04-05 12:17:50
給這個鏡頭:http://stackoverflow.com/questions/4015816/why-is-font-face-throwing-a-404-error-on-woff-files – cdwyer 2014-11-22 14:39:09