我正在尝试解决 Chrome 警告:
资源解释为字体,但使用 MIME 类型 text/html 传输
我想它正在抑制我的字体的正确加载。我在css中使用这段代码:
@font-face {
font-family: 'stereofidelic';
src: url('/css/fonts/stereofidelic.eot'); /* IE9 Compat Modes */
src: url('/css/fonts/stereofidelic.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('/css/fonts/stereofidelic.woff') format('woff'), /* Modern Browsers */
url('/css/fonts/stereofidelic.ttf') format('truetype'), /* Safari, Android, iOS */
url('/css/fonts/stereofidelic.svg#svgFontName') format('svg'); /* Legacy iOS */
}
@font-face {
font-family: 'bebasneue';
src: url('/css/fonts/BebasNeue.eot'); /* IE9 Compat Modes */
src: url('/css/fonts/BebasNeue.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('/css/fonts/BebasNeue.woff') format('woff'), /* Modern Browsers */
url('/css/fonts/BebasNeue.ttf') format('truetype'), /* Safari, Android, iOS */
url('/css/fonts/BebasNeue.svg#svgFontName') format('svg'); /* Legacy iOS */
}
@font-face {
font-family: 'karamuruh';
src: url('/css/fonts/karamuruh.eot'); /* IE9 Compat Modes */
src: url('/css/fonts/karamuruh.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('/css/fonts/karamuruh.woff') format('woff'), /* Modern Browsers */
url('/css/fontsh/karamuruh.ttf') format('truetype'), /* Safari, Android, iOS */
url('/css/fonts/karamuruh.svg#svgFontName') format('svg'); /* Legacy iOS */
}
@font-face {
font-family: 'comicnotesmooth';
src: url('/css/fonts/comicnotesmooth.eot'); /* IE9 Compat Modes */
src: url('/css/fonts/comicnotesmooth.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('/css/fonts/comicnotesmooth.woff') format('woff'), /* Modern Browsers */
url('/css/fonts/comicnotesmooth.ttf') format('truetype'), /* Safari, Android, iOS */
url('/css/fonts/comicnotesmooth.svg#svgFontName') format('svg'); /* Legacy iOS */
}
@font-face {
font-family: 'singlesleeve';
src: url('/css/fonts/singlesleeve.eot'); /* IE9 Compat Modes */
src: url('/css/fonts/singlesleeve.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('/css/fonts/singlesleeve.woff') format('woff'), /* Modern Browsers */
url('/css/fonts/singlesleeve.ttf') format('truetype'), /* Safari, Android, iOS */
url('/css/fonts/singlesleeve.svg#svgFontName') format('svg'); /* Legacy iOS */
}
@font-face {
font-family: 'TravelingTypewriter';
src: url('/css/fonts/TravelingTypewriter.eot'); /* IE9 Compat Modes */
src: url('/css/fonts/TravelingTypewriter.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('/css/fonts/TravelingTypewriter.woff') format('woff'), /* Modern Browsers */
url('/css/fonts/TravelingTypewriter.ttf') format('truetype'), /* Safari, Android, iOS */
url('/css/fonts/TravelingTypewriter.svg#svgFontName') format('svg'); /* Legacy iOS */
}
我尝试将任何类型的指令添加到我的 .htaccess 中,谷歌搜索我发现许多人的解决方案是在 .htaccess 中添加以下内容:
AddType application/vnd.ms-fontobject .eot
AddType application/octet-stream .otf .ttf
AddType font/otf .otf
AddType font/opentype .woff
但我仍然从 Chrome 收到同样的警告:
Resource interpreted as Font but transferred with MIME type text/html: "http://mydomain/css/fonts/TravelingTypewriter.woff". index.php:195
Resource interpreted as Font but transferred with MIME type text/html: "http://mydomain/css/fonts/BebasNeue.woff". index.php:195
Resource interpreted as Font but transferred with MIME type text/html: "http://mydomain/css/fonts/TravelingTypewriter.ttf". index.php:195
Resource interpreted as Font but transferred with MIME type text/html: "http://mydomain/css/fonts/BebasNeue.ttf". index.php:195
Resource interpreted as Font but transferred with MIME type text/html: "http://mydomain/css/fonts/TravelingTypewriter.svg". index.php:195
Resource interpreted as Font but transferred with MIME type text/html: "http://mydomain/css/fonts/BebasNeue.svg". index.php:195
在我的本地网络服务器上一切正常,我不需要任何 AddType 指令到 .htaccess 中。
这是在 stackoverflow.com 上建议的 24 小时谷歌搜索 + 尝试解决方案,但没有运气。
有什么帮助吗?