簡體   English   中英

來自font-awesome的字體文件有什么用?

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

我正在使用font-awesome ,它的CSS文件CDN擴展名可以正常工作。 以下是一個簡單的示例:

<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>

該示例運行良好,但是從CDN上 ,我還獲得了.otf.eot.svg.ttf.woff文件的鏈接。 如果該示例僅使用.css文件擴展名,則這些文件的用途是什么?

雖然某些瀏覽器支持TTF / OTF格式作為Web字體,但是Internet Explorer會生成錯誤,除非將字體設置為“可安裝嵌入”模式。 當.woff和.eot變體都不提供給IE時,會重現此行為。

可以通過使用以下實用程序之一將字體文件中的fsType標志設置為0000(代表可安裝的嵌入模式)來解決此問題:使用ttembed-js npm模塊

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

或者,在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);

使用原來的

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

這是因為,如果您看到該css文件,則會找到正在導入或調用所有這些文件的鏈接或代碼。 基本上,css只是顯示和調用特定圖標的代碼。 但是該圖標在那些otf和其他文件中。 就像您只能在html中調用img標簽一樣,但是為什么要在網站中保留圖片才能保存在網站中。 希望它清除

謝謝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM