font-spider 介绍
font-spider是一个智能自动化压缩工具,它能自动分析页面使用的 WebFont 并进行按需压缩,并不需要指定字体与字符。
特性
压缩字体:智能删除没有被使用的字形数据,大幅度减少字体体积
生成字体:支持 woff2、woff、eot、svg 字体格式生成
安装
npm install font-spider -g
一、书写 css
/*声明 WebFont*/@font-face {font-family: 'source';src: url('../font/source.eot');src:url('../font/source.eot?#font-spider') format('embedded-opentype'),url('../font/source.woff2') format('woff2'),url('../font/source.woff') format('woff'),url('../font/source.ttf') format('truetype'),url('../font/source.svg') format('svg');font-weight: normal;font-style: normal;}/*使用指定字体*/.home h1,.demo > .test {font-family: 'source';}特别说明: @font-face 中的 src 定义的 .ttf 文件必须存在,其余的格式将由工具自动生成二、压缩 WebFont
font-spider [options] <htmlFile1 htmlFile2 ...>htmlFiles
options
-h,--help 输出帮助信息
-V,--version 输出当前版本号
--info 输出 WebFont 的 jsON 描述信息,不压缩与转码
--ignore <pattern> 忽略的文件配置(支持正则表达式)
--map <remotePath,localPath> 映射 css 内部 HTTP 路径到本地(支持正则表达式)
GitHub:https://github.com/aui/font-spider
网站描述:一个智能 WebFont 压缩工具
font-spider
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。