最近在开发前端的时候因为设计原因使用了一些特殊的字体(otf格式),后来发现这些字体文件很大,平均一个8mb左右,严重影响了网页的效率。经过一番查找,找到了一款前端字体压缩工具(只支持utf-8格式)。font-spider.font-spider的介绍可以查看详情。http://font-spider.org/index....先安装OKNodeJS,然后执行:npminstallfont-spider-guse/*declareWebFont*/@font-face{font-family:'pinghei';src:url('../font/pinghei.eot');src:url('../font/pinghei.eot?#font-spider')格式('embedded-opentype'),url('../font/pinghei.woff')格式('woff'),url('../font/pinghei.ttf')format('truetype'),url('../font/pinghei.svg')format('svg');字体粗细:正常;字体样式:正常;}/*使用selector指定字体*/.homeh1,.demo>.test{font-family:'pinghei';}@font-face中src定义的.ttf文件必须存在,其余格式将由工具自动生成因此,你必须有一个ttf格式的字体。如果是其他类型,可以在线转换https://www.fontke.com/tool/c...生成字体运行font-spider./demo/*.html命令即可找到压缩后的字体很小,只有几k
