font-spider安装与使用
font-spider安装
先安装好 NodeJS,然后执行:
npm install font-spider -g
(安装后,会看到一堆报错、警告,不必理会)
在 CSS 中使用 WebFont
/*声明 WebFont*/ @font-face { font-family: '方正兰亭刊黑_GBK'; src: url('../fonts/方正兰亭刊黑_GBK.ttf') format('truetype'); font-weight: normal; font-style: normal; } /*使用选择器指定字体*/ body{ font-family: '方正兰亭刊黑_GBK'; }
@font-face 中的 src 定义的 .ttf 文件必须存在
运行 font-spider 命令
font-spider D:\web\helloWorld\*.html
页面依赖的字体将会自动压缩好,原始字体会存放在字体目录的.font-spider文件夹下
报错解决方案
运行npm install出现thon Python is not set from command line or npm configuration解决方案
解决方案:管理员权限打开执行:
npm install --global --production windows-build-tools
如果尝试了还是不行的话,尝试一下这个:
npm config set msvs_version 2017
参考:
https://blog.csdn.net/weixin_30443731/article/details/95472571
https://blog.csdn.net/a986436517/article/details/106882545
https://github.com/nodejs/node-gyp#installation
本站文章除注明转载/出处外,均为原创,若要转载请务必注明出处。转载后请将转载链接通过邮件告知我站,谢谢合作。本站邮箱:admin@only4.work
尊重他人劳动成果,共创和谐网络环境。点击版权声明查看本站相关条款。