使用 @font-face 在 IE 中显示无样式内容的 Flash
我正在开发一个网站,该网站使用 Open Sans 字体作为正文,并使用 Font Squirrel 生成的 EOT、SVG、WOFF 和 TTF 字体文件和样式表。我首先将字体 CSS 包含在页面标题中。但是,当我在 IE7、IE8 甚至 IE9 中查看该网站时,在 Open Sans 启动之前,我会看到 Times Roman 中的所有内容。这在其他浏览器中不会发生。
谁能建议我可以阻止这种情况发生吗?这是我用于该字体的 Font Squirrel CSS:
@font-face {
font-family: 'OpenSansRegular';
src: url('opensans-regular-webfont.eot');
src: url('opensans-regular-webfont.eot?#iefix') format('embedded-opentype'),
url('opensans-regular-webfont.woff') format('woff'),
url('opensans-regular-webfont.ttf') format('truetype'),
url('opensans-regular-webfont.svg#OpenSansRegular') format('svg');
font-weight: normal;
font-style: normal;
}
I'm working on a site which uses the Open Sans typeface for the body text, with EOT, SVG, WOFF and TTF font files and stylesheet generated by Font Squirrel. I've included my fonts CSS first in my page header. But when I view the site in IE7, IE8 and even IE9 I get a flash of everything in Times Roman before the Open Sans kicks in. This isn't happening in the other browsers.
Can anyone suggest a way I could stop this happening? Here's the Font Squirrel CSS I'm using for that font:
@font-face {
font-family: 'OpenSansRegular';
src: url('opensans-regular-webfont.eot');
src: url('opensans-regular-webfont.eot?#iefix') format('embedded-opentype'),
url('opensans-regular-webfont.woff') format('woff'),
url('opensans-regular-webfont.ttf') format('truetype'),
url('opensans-regular-webfont.svg#OpenSansRegular') format('svg');
font-weight: normal;
font-style: normal;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
下载自定义字体时您看到的内容并未在上面的代码中定义。它是在整个 CSS 代码中的其他
font-family
指令中定义的。在“OpenSansRegular”值后添加其他字体,以逗号分隔。从右到左:
serif
、sans-serif
、monospace
或cursive
(耶 Comic Sans!) 。在这里,OpenSansSth
是...sans-serif
。你的浏览器有这些家族的默认字体,Arial、Verdana 或 Linux 中的其他字体,等等。当你不为他选择时,这是用户的选择。默认系列是
serif
,Windows 中的默认字体是“Times New Roman”。这就是为什么您将 Times New Roman 视为 IE 中的 FOUC。OpenSansRegular
例如:
带有百分比的兼容性表(可能有点旧)http://www.codestyle.org/css/font-family/
不要使用 10 个值,3 到 6 个值就足够了;)在 2012 年,@font-face 可能会导致渲染问题,具体取决于浏览器和操作系统(别名),但它得到了很好的支持,因此您可以缩短字体系列。
What you see while the custom font is being downloaded isn't defined in the above code. It's defined in your other
font-family
instructions throughout your CSS code.Add other fonts after 'OpenSansRegular' value, separated by commas. From right to left:
serif
,sans-serif
,monospace
orcursive
(yay Comic Sans!). Here,OpenSansSth
is ...sans-serif
.Your browser has a default for these families, Arial, Verdana or some other font in Linux, whatever. It's the user choice when you don't choose for him. The default family is
serif
and the default font in Windows is 'Times New Roman'. That's why you see Times New Roman as a FOUC in IE.OpenSansRegular
in your siteEx:
Compatibility tables with percentages (maybe a bit old) http://www.codestyle.org/css/font-family/
Don't use 10 values, 3 to maybe 6 will be enough ;) In 2012 @font-face may cause rendering problems depending on the browser and the OS (aliasing) but it's very well supported so you can shorten your font-families.
用于隐藏
@font-face
FOUC 的 jQuery 插件可以在这里找到:如何知道字体(@font-face)是否已经加载已加载? 从此线程中删除了代码块,因为我一直在那边更新它。jQuery plugin to hide FOUC of
@font-face
can be found here: How to know if a font (@font-face) has already been loaded? Removed the code block from this thread as I have been updating it over there.