无法在Internet Explorer 8中使用@font-face

9

我在IE8浏览器中遇到了一个问题,无法显示客户定制的字体。在IE9、IE7和Chrome浏览器中都可以正常显示,但是我不知道为什么这个IE版本会出问题。这是我的HTML中的引用语句:

<!--[if IE 8]>
    <link rel="stylesheet" type="text/css" href="../styles/ie/cherokee_ie.css" />
    <![endif]-->

这里是cherokee_ie.css文件。

@font-face {
font-family: 'cherokee';
src: url('../../custom.eot');
src: url('../../custom.eot') format('embedded-opentype'),
src: local('☺'), url('../../font/custom.woff') format('woff'), url('../../font/custom.ttf')             format('truetype'), url('../../font/custom.svg') format('svg');
font-weight: normal;
font-style: normal;
}

h1 ul li {
  font-family:cherokee;
}

我不确定src: local后面的笑脸符号有什么作用,但我在另一个S.O.问题中找到了这段代码,可以完美地在IE7中运行(或者至少在BrowserLab中看起来是这样)。
此外,是否有比Browserlab更快的方法生成视图?

2
关于这个笑脸:它可以阻止Internet Explorer读取该值的其余部分并尝试使用其他类型的字体及其format(),而IE不支持这些。 - Ry-
哦,不错。我不知道你可以这样做。这是特殊字符才能做到的吗?还是任何空字符都可以这样做? - Matt Zelenak
2
任何东西都可以使用 - 诀窍在于IE根本不支持local()。 使用不常见的字符的原因是防止实际的本地字体被访问,这有时可能会导致安全问题。 这篇文章提供了更多信息。 - Ry-
1
你确定你的 IE 条件语句是必要的吗? - worenga
1个回答

4
删除IE条件语句并将其放入CSS中。
@font-face {
    font-family: 'cherokee';
    src: url('../../custom.eot');
    src: url('../../custom.eot?#iefix') format('embedded-opentype'),
         url('../../font/custom.woff') format('woff'),
         url('../../font/custom.ttf') format('truetype'),
         url('../../font/custom.svg#cherokee') format('svg');
    font-weight: normal;
    font-style: normal;

}

您可以像这样使用“...”来自定义font-face字体:
h1 ul li {
  font: 18px/27px 'cherokee', Arial, sans-serif;
}

请检查您的路径是否设置正确。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接