我正在尝试使文件内的字体呈现,但它一直给我一个通常的错误提示。
我正在尝试使文件内的字体呈现,但它一直给我一个通常的错误提示。
Resource interpreted as Font but transferred with MIME type text/html:
但是展示的HTML文件是我们的404.aspx文件,我尝试了通常的方法,将应用程序安装在web.config中,并最终安装到IIS本身中:
.woff application/font-woff
.ttf application/font-ttf
.eot application/vnd.ms-fontobject
.otf application/font-otf
.svg image/svg+xml
我搞不明白哪里出了问题。这些文件存储在一个名为fonts的文件夹中,该文件夹位于网站的基本目录中,并且我已经在我的aspx文件中加入了样式。
@font-face {
font-family: 'segoe_printregular';
src: url('/fonts/segoepr-webfont.eot'); /* IE9 Compat Modes */
src: url('/fonts/segoepr-webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('/fonts/segoepr-webfont.woff') format('woff'), /* Modern Browsers */
url('/fonts/segoepr-webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('/fonts/segoepr-webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
font-weight: normal;
font-style: normal;
}
并且将fonts文件夹中的stylesheet.css文件设为:
@font-face {
font-family: 'segoe_printregular';
src: url('/segoepr-webfont.eot'); /* IE9 Compat Modes */
src: url('/segoepr-webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('/segoepr-webfont.woff') format('woff'), /* Modern Browsers */
url('/segoepr-webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('/segoepr-webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
font-weight: normal;
font-style: normal;
}
我已经尝试了文件路径为/fonts/和fonts/,但没有成功。但我无法使文件不出现404错误。有人建议重新启动服务器,但这也没有实现任何效果。
我是否漏掉了什么?或者我犯了某些错误吗?
如果有帮助的话,我也在web.config中尝试过这个。
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<remove fileExtension=".ttf" />
<mimeMap fileExtension=".ttf" mimeType="application/font-ttf" />
<remove fileExtension=".eot" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<remove fileExtension=".otf" />
<mimeMap fileExtension=".otf" mimeType="application/font-otf" />
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>