字體文件使用及壓縮


字蛛鏈接:附:http://font-spider.org/

1.字體文件可以獲取任意一類,然后去網站生成兼容不同瀏覽器的文件。一般情況下,在網上能搜到字體的類型文件:ttf。

https://www.fontke.com/tool/convfont/?fromlang=zh_CN

2.字體文件太大,一般選擇用字蛛去壓縮字體文件。

安裝命令:

npm install font-spider -g

在 CSS 中使用 WebFont:

/*聲明 WebFont*/
@font-face {
  font-family: 'pinghei';
  src: url('../font/pinghei.eot');
  src:
    url('../font/pinghei.eot?#font-spider') format('embedded-opentype'),
    url('../font/pinghei.woff') format('woff'),
    url('../font/pinghei.ttf') format('truetype'),
    url('../font/pinghei.svg') format('svg');
  font-weight: normal;
  font-style: normal;
}

/*使用選擇器指定字體*/
.home h1, .demo > .test {
    font-family: 'pinghei';
}

1. @font-face 中的 src 定義的 .ttf 文件必須存在,其余的格式將由工具自動生成

2. 開發階段請使用相對路徑的 CSS 與 WebFont

運行:

font-spider ./demo/*.html

使用注意:文件目錄這樣創建:

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM