CSS 如何将 OTF/TTF 文件转换为 EOT 格式?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1979826/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 21:24:38  来源:igfitidea点击:

How can I convert OTF/TTF files to EOT format?

cssbrowserfontstype-conversionfont-face

提问by newbie

I need to use @font-face feature and my fonts are in OTF/TTF format and Microsoft browsers support only EOT format. I tried to use Microsoft tool WEFT, but it didn't work or I didn't understand how it works. Is there any other way to convert my fonts to EOT format?

我需要使用 @font-face 功能,我的字体是 OTF/TTF 格式,Microsoft 浏览器仅支持 EOT 格式。我尝试使用 Microsoft 工具 WEFT,但它不起作用或我不明白它是如何工作的。有没有其他方法可以将我的字体转换为 EOT 格式?

回答by Peter Boughton

Use the Font Squirrel Generator- this will produce not just EOT, but also SVG and WOFF formats, and converting multiple font files at once, and providing everything in a single archive along with the relevant CSS.

使用字体松鼠生成器- 这不仅会生成 EOT,还会生成 SVG 和 WOFF 格式,并一次转换多个字体文件,并在单个存档中提供所有内容以及相关的 CSS。

回答by apinstein

Here's a quick way to build ttf and eot versions from otf in one step. Of course you can pull out the relevant parts if you don't need all of it. Note that you to get eot from otf you have to go otf->ttf->eot.

这是一种快速从 otf 一步构建 ttf 和 eot 版本的方法。当然,如果您不需要全部,您可以将相关部分拉出。请注意,要从 otf 获取 eot,您必须转到 otf->ttf->eot。

Install both fontforge and ttf2eot. They are available in MacPorts, not sure about other platforms.

安装 fontforge 和 ttf2eot。它们在 MacPorts 中可用,不确定其他平台。

Save this as a script file named otf2ttf2eot.sh:

将其保存为名为 otf2ttf2eot.sh 的脚本文件:

(This script has been updated for new fontforge versions; original script at end of post):

(此脚本已针对新的 fontforge 版本进行了更新;原始脚本在帖子末尾):

#!/bin/sh
otfFont=".otf"
ttfFont=".ttf"
eotFont=".eot"
fontforge -c '
import fontforge
font = fontforge.open("'$otfFont'")
font.generate("'$ttfFont'")
'
ttf2eot "$ttfFont" >"$eotFont"

Assuming you have a font named FontName.otf, run:

假设您有一个名为 FontName.otf 的字体,请运行:

sh otf2ttf2eot.sh FontName

sh otf2ttf2eot.sh 字体名称

Original script for older versions of fontforge:

旧版本 fontforge 的原始脚本:

#!/bin/sh
# Convert an OTF font into TTF an EOT formats.
otfFont=".otf"
ttfFont=".ttf"
eotFont=".eot"
fontforge -c '
    Open("'$otfFont'");
    Generate("'$ttfFont'");
    Quit(0);'
ttf2eot $ttfFont > $eotFont

回答by Federico

In Ubuntu, install mkeot:

在 Ubuntu 中,安装mkeot

sudo apt-get install eot-utils

Then:

然后:

mkeot fontfilename.otf > fontfilename.eot

回答by Mark Martin

Use http://www.font2web.com/- this will produce not just EOT, but also SVG and WOFF formats, and converting multiple font files at once, and providing everything in a single archive along with the relevant CSS.

使用http://www.font2web.com/- 这不仅会生成 EOT,还会生成 SVG 和 WOFF 格式,并一次转换多个字体文件,并在单个存档中提供所有内容以及相关的 CSS。

回答by dors

Also worth checking is everything fonts font-face converter. This has woff2 and EOT support as well.

同样值得检查的是所有字体字体字体转换器。这也有 woff2 和 EOT 支持。

https://everythingfonts.com/font-face

https://everythingfonts.com/font-face

If you just want eot conversion they have that too.

如果你只是想要 eot 转换,他们也有。

https://everythingfonts.com/otf-to-eot

https://everythingfonts.com/otf-to-eot

回答by Guman Thakur

http://www.flaticon.com/font-face

http://www.flaticon.com/font-face

For me, it returned all the font type in a zipped file

对我来说,它返回了压缩文件中的所有字体类型