2013-02-21 92 views
0

工作我用下面的代碼在我的ASP.NET網站顯示自定義字體:字體面不是在IE和鉻

<style type="text/css"> 
@font-face { 
    font-family: 'B Mitra'; 
    src: url('BMitra.ttf') format('truetype'); /* IE9 Compat Modes */ 
    src: url('BMitra.ttf?#iefix') format('truetype'), /* IE6-IE8 */ 
     url('BMitra.ttf') format('truetype'), /* Modern Browsers */ 
     url('BMitra.ttf') format('truetype'); /* Safari, Android, iOS */ 
    } 
    </style> 
</head> 


<body style="font-family:B Mitra;" onload="pageLoad()"> 

它工作在Firefox罰款,但IE和Chrome不要」 t顯示我的自定義字體(這個自定義字體位於我的服務器,在包含我的ASPX文件的文件夾中,字體在沒有它在Firefox中的系統上下載,但我認爲IE和Chrome無法下載它和另一個現有的字體被使用)。這裏出了什麼問題?

回答

0

http://www.adtrak.co.uk/blog/font-face-chrome-rendering/

你爲什麼只調用相同的格式( 'TrueType字體')一遍又一遍?在它旁邊註釋並不能解決現代瀏覽器的問題。我認爲你還需要其他文件格式?也就是說,通常爲:

@font-face { 
font-family: 'chunk-webfont'; 
src: url('../../includes/fonts/chunk-webfont.eot'); 
src: url('../../includes/fonts/chunk-webfont.eot?#iefix') format('eot'), 
url('../../includes/fonts/chunk-webfont.woff') format('woff'), 
url('../../includes/fonts/chunk-webfont.ttf') format('truetype'), 
url('../../includes/fonts/chunk-webfont.svg') format('svg'); 
font-weight: normal; 
font-style: normal; 
} 

@media screen and (-webkit-min-device-pixel-ratio:0) { 
@font-face { 
font-family: 'chunk-webfont'; 
src: url('../../includes/fonts/chunk-webfont.svg') format('svg'); 

} 
} 
+0

謝謝,但我只有一個ttf文件,我怎麼能找到我的字體的其他格式?我應該轉換它們嗎?你的意思是我應該使用其他格式的IE或鉻?一切工作正常FireFox – 2013-02-21 08:30:26

+0

轉換將是最簡單的,這是我會做的。有幾個地方可以做到這一點,就像這裏 http://www.fontsquirrel.com/tools/webfont-generator – emmy 2013-02-21 08:36:55

+0

如果你不轉換,這個人有你需要的字體需要你需要的格式 https://github.com/sobhe/jahadi/tree/master/static/fonts – emmy 2013-02-21 08:44:06