简体   繁体   English

来自font-awesome的字体文件有什么用?

[英]What is the use for font files from font-awesome?

I am using font-awesome and it works fine with its CDN extension for CSS files. 我正在使用font-awesome ,它的CSS文件CDN扩展名可以正常工作。 Following is a simple example: 以下是一个简单的示例:

<html>
    <head>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.css">
    </head>
    <body>
        <i class="fa fa-adjust"></i>
    </body>
</html>

The example runs fine, but from the CDN , I also get links for .otf , .eot , .svg , .ttf , .woff files. 该示例运行良好,但是从CDN上 ,我还获得了.otf.eot.svg.ttf.woff文件的链接。 What is the use of these files if the example renders well with only .css file extension? 如果该示例仅使用.css文件扩展名,则这些文件的用途是什么?

While some browsers support the TTF/OTF formats as webfonts, Internet Explorer generates an error unless the font is set to Installable Embedding mode. 虽然某些浏览器支持TTF / OTF格式作为Web字体,但是Internet Explorer会生成错误,除非将字体设置为“可安装嵌入”模式。 This behavior is reproduced when neither .woff nor .eot variants are served to IE. 当.woff和.eot变体都不提供给IE时,会重现此行为。

This can be remedied by setting the fsType flag in the font file to 0000, representing Installable Embedding mode, using one of the following utilities: Using the ttembed-js npm module 可以通过使用以下实用程序之一将字体文件中的fsType标志设置为0000(代表可安装的嵌入模式)来解决此问题:使用ttembed-js npm模块

npm install -g ttembed-js
ttembed-js path/to/fontawesome-webfont.ttf
ttembed-js path/to/FontAwesome.otf

or, within node.js: 或者,在node.js中:

var callback = function(error, oldFsType) {
    if (error) {
        console.error('Something went wrong.', error);
        return;
    }
    if (oldFsType === '0000') {
        console.log('fsType is already 0000; no action taken.');
    } else {
        console.log('fsType successfully changed from ' + oldFsType + ' to 0000.');
    }
}
var ttembed = require('ttembed-js');
ttembed({filename: './path/to/fontawesome-webfont.ttf'}, callback);
ttembed({filename: './path/to/FontAwesome.otf'}, callback);

Using the original ttembed 使用原来的

git clone https://github.com/hisdeedsaredust/ttembed.git
cd ttembed
make
./ttembed path/to/fontawesome-webfont.ttf path/to/FontAwesome.otf

It is because if you see that css file you will find the links or code which is importing or calling all these files. 这是因为,如果您看到该css文件,则会找到正在导入或调用所有这些文件的链接或代码。 basically css is just the code which shows and calls the particular icon. 基本上,css只是显示和调用特定图标的代码。 but that icon is in those otf and other files. 但是该图标在那些otf和其他文件中。 its like you can only call img tag in the html but why you need a image in your website to be kept in a website. 就像您只能在html中调用img标签一样,但是为什么要在网站中保留图片才能保存在网站中。 hope it clears 希望它清除

thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM