使用Font-Spider提取字体
使用font-spider提取页面需要的特定字体,并使用在线字体转换工具转换为Base64
1、安装
安装node,全局安装font-spider
NPM工具包
npm install font-spider -g
或者
cnpm install font-spider -g
2、新建一个HTML,引入字体包
- 新建
./index.html
- 字体包放在
./font/**.ttf
路径下
<html>
<style>
@font-face {
font-family: font;
src: url('./font/xxx.TTF');
}
.font {
font-family: font;
}
</style>
</html>
<body>
<div class="font">0123456789</div>
</body>
3、使用命令行提取字体
原字体移动到./.font-spider/**.ttf
,新字体替换原字体
font-spider *.html
4、使用在线工具转换为Base64
- 点击 Add fonts 按钮, 上传 .ttf 字体文件
- 打开 Family support 和 Base64 encode 开关, Formats 只选择 "WOFF2" 选项
- 点击 Convert 按钮
转换完成后会生成下载链接, 点击 Download 下载即可,解压后只需要css文件