【ttf 壓縮】html網頁引用中文字體,文件過大,加載緩慢的解決辦法【字蛛】【web font】
【字蛛】http://font-spider.org/
先安裝好 NodeJS,然后執行:
npm install font-spider -g
安裝后,會看到一堆報錯、警告,不必理會
在 CSS 中使用 WebFont:
/*聲明 WebFont*/
@font-face {
font-family: '方正蘭亭刊黑_GBK';
src: url('../fonts/方正蘭亭刊黑_GBK.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
/*使用選擇器指定字體*/
body{
font-family: '方正蘭亭刊黑_GBK';
}
@font-face 中的 src 定義的 .ttf 文件必須存在
運行 font-spider 命令:
font-spider D:\web\helloWorld\*.html
頁面依賴的字體將會自動壓縮好