!!!压缩的只有调用字体的文字
- 字蛛压缩后有些文字不起作用
字蛛在压缩过程中只将调用字体的文字进行压缩,其他文字将不被压缩
1.准备
在页面中引用字体
<html>
<head>
<!-- <link rel="stylesheet" href="css/font.css"> -->
<style type="text/css">
@font-face {
font-family: "aa";
/*ttf字体路径*/
src: url("./font/字体.ttf");
font-weight: normal;
font-size: noraml;
}
body{
/*引用字体*/
font-family: 'aa';
}
</style>
</head>
<body>
<!--所需要压缩的所有字体 ,末尾有提供3000个常见汉字足够平时使用-->
</body>
</html>
2.用字蛛进行压缩
-
npm install font-spider -d
-
输入命令行进行压缩 :
npm ./node_modules/.bin/font-spider index.html
npx font-spider index.html
这里用到局部安装,访问需要:./node_modules/.bin/font-spider或npx
这里的目录结构为:index.html与node_modules同级,font存放字体
font文件夹下的为压缩字体,font下font-spider 文件夹里是原字体文件
常见与不常见
3000个常见汉字链接,数字,字母,字符等自行添加