在网页中加载外部字体。 Internet Explorer 的解决方案?

发布于 2024-11-28 22:31:07 字数 103 浏览 6 评论 0原文

在所有像样的网络浏览器中,@font-face 只是用于将外部字体加载到您的网页中。但是,对于 IE9 之前的 IE 版本,这不起作用。我想使用 Ubuntu 字体系列。 有什么绝妙的想法吗?

In all decent webbrowsers @font-face just works for loading an external font into your webpage. However, for IE versions older than IE9 this does not work. I'd like to use the Ubuntu Font Family.
Any brilliant ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浸婚纱 2024-12-05 22:31:07

FontSquirrel 将为您创建正确的跨浏览器 CSS。

CSS 示例:

@font-face {
    font-family: 'DroidSansRegular';
    src: url('/resources/fonts/DroidSans-webfont.eot');
    src: url('/resources/fonts/DroidSans-webfont.eot?#iefix') format('embedded-opentype'),
         url('/resources/fonts/DroidSans-webfont.woff') format('woff'),
         url('/resources/fonts/DroidSans-webfont.ttf') format('truetype'),
         url('/resources/fonts/DroidSans-webfont.svg#DroidSansRegular') format('svg');
    font-weight: normal;
    font-style: normal;
}

这适用于 IE7 及更高版本,当然还有所有其他浏览器。

FontSquirrel will create the proper cross-browser CSS for you.

Example CSS:

@font-face {
    font-family: 'DroidSansRegular';
    src: url('/resources/fonts/DroidSans-webfont.eot');
    src: url('/resources/fonts/DroidSans-webfont.eot?#iefix') format('embedded-opentype'),
         url('/resources/fonts/DroidSans-webfont.woff') format('woff'),
         url('/resources/fonts/DroidSans-webfont.ttf') format('truetype'),
         url('/resources/fonts/DroidSans-webfont.svg#DroidSansRegular') format('svg');
    font-weight: normal;
    font-style: normal;
}

This works in IE7 and above and, of course, all other browsers.

浪菊怪哟 2024-12-05 22:31:07

您可以看看这篇文章

浏览器支持

这让我陷入了另一个主要问题,即浏览器支持。字体
嵌入 TrueType 或 OpenType 字体仅适用于 Firefox
3.5、Safari 3.1 和 Opera 10。(您可以在您的
Chrome 2 通过使用命令行开关。)

好吧,这已经很不错了,但我们可以做得更好。我们可以上网
Explorer 4+、Chrome 0.3+、Opera 9+ 甚至还有一些移动版 Safari
行动。结束时间

Internet Explorer 支持一种称为“嵌入式”的特殊格式
OpenType 提供对字体位置和方式的一些控制
允许嵌入。您需要将 TTF 转换为 EOT
格式。微软提供了一个名为 WEFT 的工具,但它很古老并且
如果我能让它工作的话我会被诅咒的。幸好有一个命令
名为 TTF2EOT 的线条工具可以转换您的字体。

另外: 如何将外部字体加载到 HTML 文档中?

You can have a look at this article:

Browser Support

Which leads me into the other major issue, browser support. Font
embedding with a TrueType or OpenType font only works as of Firefox
3.5, Safari 3.1, and Opera 10. (You can enable it in your copy of
Chrome 2 by using a command line switch.)

Okay, that's decent already but we can do better. We can get Internet
Explorer 4+, Chrome 0.3+, Opera 9+ and even a little mobile Safari
action. EOT

Internet Explorer supports a particular type of format called Embedded
OpenType that provides some control over where and how the font is
allowed to be embedded. You'll need to convert your TTF into an EOT
format. Microsoft provides a tool called WEFT but it is ancient and
I'll be damned if I can get it working. Thankfully, there is a command
line tool called TTF2EOT that can convert your font.

Also: How do I load external fonts into an HTML document?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文