新建package.json 内容{}
使用管理员身份运行cmd
输入: cd /d D:\FromGithub\FontModify 进入待压缩字体的目录
下载fontmin模板:
npm i fontmin --save
下载完成后,编写min.js文件 内容如下:
const Fontmin=require('fontmin');
new Fontmin()
.src('arial.ttf') //源字体文件地址
.dest('res/') //压缩后存放地址
.use(Fontmin.glyph({
text:"0123456789abc启动", //要提取的字符
hinting:false
}))
.use(Fontmin.ttf2woff({
deflate:true
}))
.run();
最后在控制台输入:node min.js
这样就完成了字体压缩。
官网:http://ecomfe.github.io/fontmin/
Github:https://github.com/ecomfe/fontmin
评论0