1. 下载字蛛,全局安装
npm install font-spider -g
2. 创建一个自己的文件夹 如 test
包含下面三个目录
1. css文件夹 (font.css)
2. font文件夹 (字体1.ttf,字体2.ttf)
3. index.html
3. font.css
@font-face {
font-family: 'sf-pro-text_regular';
src: url('../font/sf-pro-text_regular.ttf') format('truetype'),
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'sf-pro-text_semibold';
src: url('../font/sf-pro-text_semibold.ttf') format('truetype'),
font-weight: normal;
font-style: normal;
}
body{
font-family:"sf-pro-text_regular";
}
.tt1{
font-family: 'sf-pro-text_regular';
font-size: 24px;
color: #333;
}
.tt2{
font-family: 'sf-pro-text_semibold';
font-size: 24px;
color: #333;
}
4. index.html
<html>
<head>
<link rel="stylesheet" href="css/font.css">
</head>
<body>
<p class="tt1">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:,;'"(!?)+-*/=</p>
<p class="tt2">abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:,;'"(!?)+-*/=</p>
</body>
</html>
5. 进入test目录下 运行如下命令
font-spider ./*.html
6.font文件夹下会生成对应的压缩字体文件
font文件夹下的 .font-spider 文件夹里是原字体文件