css - IE 8 将字体正常呈现为斜体

标签 css internet-explorer font-face

我一直在思考是什么导致某些 IE 版本将 @font-face 字体呈现为斜体,即使这些样式被声明为正常。

我的主要想法是 IE 不会在呈现页面之前下载每个字体文件。

在我的 CSS 中,我已经为相同字体的不同字体声明了字体文件 - 从细斜体到超斜体。它们都使用相同的设置声明:

@font-face { /* THIN ITALIC */
    font-family: Unit;
    src: url("../gfx/fonts/UnitWeb-ThinIta.eot")
    src: url("../gfx/fonts/UnitWeb-ThinIta.eot?#iefix") format("embedded-opentype"),
         url("../gfx/fonts/UnitWeb-ThinIta.woff") format("woff");
    font-weight: 100;
    font-style: italic, oblique;
    font-variant: normal;
}

通过

@font-face { /* ULTRA */
    font-family: Unit;
    src: url("../gfx/fonts/UnitWeb-Ultra.eot");
    src: url("../gfx/fonts/UnitWeb-Ultra.eot?#iefix") format("embedded-opentype"),
         url("../gfx/fonts/UnitWeb-Ultra.woff") format("woff");
    font-weight: 900;
    font-style: normal;
    font-variant: normal;
}

正如您所见,斜体被声明为 font-style: italic, oblique;,而 normal 被声明为 font-style: normal;

现在,渲染。

This is how IE 9 renders it

This is how IE 8 renders it every now and then

最佳答案

作为答案发布的是这个 SO 问题:Custom font sometimes renders in italics in IE8 / IE7


您需要为每个@font-face 字体系列创建一个自定义名称。例如

@font-face { /* THIN ITALIC */
   font-family: UnitItalic;
   src: url("../gfx/fonts/UnitWeb-ThinIta.eot")
   src: url("../gfx/fonts/UnitWeb-ThinIta.eot?#iefix") format("embedded-opentype"),
        url("../gfx/fonts/UnitWeb-ThinIta.woff") format("woff");
   font-weight: 100;
   font-style: italic, oblique;
   font-variant: normal;
}


@font-face { /* THIN ITALIC */
   font-family: UnitNormal;
   src: url("../gfx/fonts/UnitWeb-ThinIta.eot")
   src: url("../gfx/fonts/UnitWeb-ThinIta.eot?#iefix") format("embedded-opentype"),
        url("../gfx/fonts/UnitWeb-ThinIta.woff") format("woff");
   font-weight: 100;
   font-style: italic, oblique;
   font-variant: normal;
}

关于css - IE 8 将字体正常呈现为斜体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14274118/

相关文章:

css - 如果超过 n 行,则淡出最后一行文本

css - @font-face 不工作

css - @font-face 在 Chrome 和 Firefox 中不工作

ruby-on-rails - 无法解码下载的字体 glyphicons-halflings-regular.woff2 - Rails,生产

html - 我的导航栏在 FF 中的位置不正确

asp.net - 从 ASP.NET 中的某些控件中删除 CSS

css - Wordpress 网站在谷歌浏览器中崩溃

javascript - 过渡结束事件未在 IE 中触发

internet-explorer - 在 Powershell 中打开浏览器刚刚停止工作

webpack:新的 css-loader 4.0.0 尝试加载字体(使它们嵌入);如何禁用这个?