【发布时间】:2014-06-04 16:51:25
【问题描述】:
在 IE7 和 IE8 中,当使用自定义 Web 字体时,文本有时会以斜体呈现,即使我明确设置了 font-style: normal。问题是零星的——它会渲染几次,然后我刷新,一切都用斜体显示,然后我刷新,它又恢复正常了。
我正在使用这个@font-face 声明:
@font-face {
font-family: 'DIN';
src: url('fonts/DINWeb.eot');
src: url('fonts/DINWeb.eot?#iefix') format('embedded-opentype'),
url('fonts/DINWeb.woff') format('woff');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'DIN';
src: url('fonts/DINWeb-Bold.eot');
src: url('fonts/DINWeb-Bold.eot?#iefix') format('embedded-opentype'),
url('fonts/DINWeb-Bold.woff') format('woff');
font-weight: bold;
font-style: normal;
}
@font-face {
font-family: 'DIN';
src: url('fonts/DINWeb-Ita.eot');
src: url('fonts/DINWeb-Ita.eot?#iefix') format('embedded-opentype'),
url('fonts/DINWeb-Ita.woff') format('woff');
font-weight: normal;
font-style: italic;
}
@font-face {
font-family: 'DIN';
src: url('fonts/DINWeb-BoldIta.eot');
src: url('fonts/DINWeb-BoldIta.eot?#iefix') format('embedded-opentype'),
url('fonts/DINWeb-BoldIta.woff') format('woff');
font-weight: bold;
font-style: italic;
}
this article 上的 a comment 表明它可能与 @font-face 声明的顺序有关:但是唯一阻止问题的方法是完全删除斜体声明。
Another Stack Overflow answer 建议使用 Font Squirrel @font-face 生成器;但是我不能这样做,因为我使用的网络字体文件有 DRM。
有没有办法在不完全删除斜体声明的情况下解决这个问题?
更新:经过进一步调查,似乎这个问题也会影响 IE8,而不仅仅是兼容模式。
【问题讨论】:
-
您没有提供正在使用的 HTML。尝试使用唯一的
@font-face姓氏。示例:DINnormal, DINbold, DINitalic, DINboldItalic。在SO Answer 中查看 CSS 和 HTML 示例。如果创建唯一名称可以解决您的问题,我会回答。干杯! -
@arttronics 谢谢,原来独特的字体系列名称最终解决了问题。如果你写了一个答案,我会继续接受它。
-
亚当夏普,很高兴这对你有用……我已经发布了答案。干杯!
标签: css internet-explorer-8 internet-explorer-7 font-face italic