解决方案: IE8似乎不支持JSF的资源加载。我将src网址更改为相对路径,现在字体已经加载:
//this wasn't working for me, 404'ing in IE8
src: url( #{resource['theme/fonts:mycustom_regular-roman-webfont.eot?#iefix']} ) format('embedded-opentype'),
//this works for me in IE8
src: url( ../resources/theme/fonts/mycustom_regular-roman-webfont.eot?#iefix ) format('embedded-opentype'),
我正在尝试在JSF2应用程序和IE8中使用自定义Web字体。这些字体在其他浏览器中工作正常,但我似乎在eot和svg的mime类型上遇到了问题。在IE8中发生的情况是我得到了在CSS中声明的非Web字体回退。
这是我的web.xml文件:
<!-- web fonts -->
<mime-mapping>
<extension>eot</extension>
<mime-type>application/vnd.ms-fontobject</mime-type>
</mime-mapping>
<mime-mapping>
<extension>otf</extension>
<mime-type>font/opentype</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ttf</extension>
<mime-type>application/x-font-ttf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>woff</extension>
<mime-type>application/x-font-woff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>svg</extension>
<mime-type>image/svg+xml</mime-type>
</mime-mapping>
这是控制台告诉我的:
[4/23/13 10:59:37:522 PDT] 0000001f context W JSF1091: No mime type could be found for file omnesods_medium-roman-webfont.eot?#iefix. To resolve this, add a mime-type mapping to the applications web.xml.
[4/23/13 10:59:37:530 PDT] 0000001f context W JSF1091: No mime type could be found for file omnesods_medium-roman-webfont.svg#omnes_ods_regularitalic. To resolve this, add a mime-type mapping to the applications web.xml.
[4/23/13 10:59:37:534 PDT] 0000001f context W JSF1091: No mime type could be found for file omnesods_medium-italic-webfont.eot?#iefix. To resolve this, add a mime-type mapping to the applications web.xml.
[4/23/13 10:59:37:541 PDT] 0000001f context W JSF1091: No mime type could be found for file omnesods_medium-italic-webfont.svg#omnes_ods_regularitalic. To resolve this, add a mime-type mapping to the applications web.xml.
[4/23/13 10:59:37:546 PDT] 0000001f context W JSF1091: No mime type could be found for file omnesods_regular-roman-webfont.eot?#iefix. To resolve this, add a mime-type mapping to the applications web.xml.
[4/23/13 10:59:37:552 PDT] 0000001f context W JSF1091: No mime type could be found for file omnesods_regular-roman-webfont.svg#omnes_ods_regularregular. To resolve this, add a mime-type mapping to the applications web.xml.
[4/23/13 10:59:37:557 PDT] 0000001f context W JSF1091: No mime type could be found for file omnesods_regular-italic-webfont.eot?#iefix. To resolve this, add a mime-type mapping to the applications web.xml.
[4/23/13 10:59:37:564 PDT] 0000001f context W JSF1091: No mime type could be found for file omnesods_regular-italic-webfont.svg#omnes_ods_regularitalic. To resolve this, add a mime-type mapping to the applications web.xml.
这是我在CSS文件中声明字体的方式:
@font-face {
font-family: 'mycustom_regularregular';
src: url( #{resource['theme/fonts:mycustom_regular-webfont.eot']} );
src: url( #{resource['theme/fonts:mycustom_regular-webfont.eot?#iefix']} ) format('embedded-opentype'),
url( #{resource['theme/fonts:mycustom_regular-webfont.woff']} ) format('woff'),
url( #{resource['theme/fonts:mycustom_regular-webfont.ttf']} ) format('truetype'),
url( #{resource['theme/fonts:mycustom_regular-webfont.svg#omnes_ods_regularregular']} ) format('svg');
font-weight: normal;
font-style: normal;
}
下面是样式表的加载方式:
<h:outputStylesheet library="theme" name="stylesheet.css" target="head" />
有人有什么想法吗?
编辑:好奇心驱使我启动了Fiddler 2,在IE8中,我的Web字体出现404错误,但在Chrome的网络面板中,我可以看到它正常加载字体。你知道为什么IE8会出现404错误吗?另外有趣的是,Firebug在Net面板中没有显示字体,但我可以直观地看到它们被下载/加载,并通过Firebug打开/关闭/更改。
url("#{resource['fonts/glyphicons-halflings-regular.eot']}?#iefix")
- samael