执行命令
sudo npm install font-spider -g
下载到本地后,执行下面的命令查看版本号:
font-spider --version
准备html静态文件:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>字体抽取</title> </head> <style> @charset "UTF-8"; @font-face { font-family: 'huakang'; src: url('../font/华康俪金黑W8.eot'); src: url('../font/华康俪金黑W8.eot?#font-spider') format('embedded-opentype'), url('../font/华康俪金黑W8.woff') format('woff'), url('../font/华康俪金黑W8.ttf') format('truetype'), url('../font/华康俪金黑W8.svg') format('svg'); font-weight: normal; font-style: normal; } /* @font-face { font-family: 'huakang'; src: url('../font/华康俪金黑W8.ttf'); } */ .box { font-family: 'huakang'; } </style> <body> <div class="box"> 扶贫公告政策二十条资讯动漫说 </div> </body> </html>
注意:这里的css 文件不能以引用的方式,必须 把css代码全部写在本页面。
所有的font的文件 使用相对路径,保证可以正常访问到!
然后执行 :
font-spider index.html Font family: hyjk Original size: 3699.336 KB Include chars: 上不东为也产京人们关决都销间 Chars length: 60 Font id: 7bb0490ba947ce06c73db7683f19d30a CSS selectors: .box, .tips, .right Font files: File static\font\hyjk.ttf created: 24.784 KB
说明执行成功,会把原来的ttf直接压缩掉,原文件也会进行备份到.font-spider目录下,挺好用的。
有需要的朋友 赶快去试试吧。。
手机扫一扫转发分享