有效的压缩字体方法

有效的压缩字体方法,第1张

该方法是单纯对字体包的压缩,压缩后可应用于网页中,提高加载速度。

1、使用 fonttools 压缩字体文件

需要 Python 环境,并已安装好 pip

使用 pip 来安装 fonttools

pip install fonttools

自行搜索下载已经整理好的字体编码列表文件 sc_unicode.txt。 

输入命令

pyftsubset YouYuan.ttf --unicodes-file=sc_unicode.txt

执行后

 

整个流程的命令截图(安装python -》安装pip-》压缩文字):

 2、转换成woff2 字体文件

在这个国外的平台里,把字体换成woff2格式CloudConvert>File converter service - more than 200 different audio, video, document, ebook, archive, image, spreadsheet and presentation formats supported.https://cloudconvert.com/

 最后只有712kb

 总结:从开始6m多的字体压缩成700多kb的字体文件,需要按照按照上面2步走。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/799423.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-06
下一篇 2022-05-06

发表评论

登录后才能评论

评论列表(0条)

保存