html文字标签压缩,tool 使用font-spider解决字体压缩问题

开发页面时经常需要使用特殊字体,一个.ttf文件动则几M,字体文件需要优化

http://font-spider.org/

安装好node环境后

1.全局安装font-spider

npm install font-spider -g

2.如果字体不全是写在html中的,那么写个文件用于生成字体

*.ttf文件必须有,其他格式的程序将自动生成

1) getFont.html文件

document

@font-face {

font-family: ‘hk‘;

src: url(‘./font/hk.eot‘);

src:

url(‘./font/hk.eot?#font-spider‘) format(‘embedded-opentype‘),

url(‘./font/hk.woff‘) format(‘woff‘),

url(‘./font/hk.ttf‘) format(‘truetype‘),

url(‘./font/hk.svg‘) format(‘svg‘);

font-weight: normal;

font-style: normal;

}

.myFont{font-family: ‘hk‘;}

这里写需要用到的字体...

2) 将 hk.tff文件放在同级font目录中

20180110222901367868.png

3. cd到目录中 执行

font-spider getFont.html

如遇到报错:Error: Expecting a function in instanceof check, but got undefined

修改

node_modules\font-spider\src\spider\index.js 文件

中的getWebFonts函数

将以下判断去除

// if (cssRule instanceof CSSFontFaceRule) {

// }

20180110222901368845.png

原文:http://www.cnblogs.com/lzs-888/p/6344719.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值