font-spider
font-spider copied to clipboard
--ignore的正确用法?
我实在是搞不懂了……求各位指教:
我要排除两个字体家族,FontAwesome和Glyphicons Halflings。目录结构:
- example <-- 根目录,所有html文件都在这,shell位置。
- site
- libs
- bootstrap
- fonts
- glyphicons-halflings-regular.eot/svg/ttf/woff/woff2 <-- 忽略
- font-awesome
- fontawesome-webfont.ttf <-- 忽略
- styles
- fontawesome
- fontawesome-webfont.eot/svg/ttf/woff/woff2 <-- 忽略
- fonts
- 中文字体.oet/svg/ttf/woff/woff2 <-- 不忽略
先尝试仅排除第二个FA字体:
--ignore styles/fontawesome/fontawesome-webfont*
返回结果
{ id: '5a5350b6467773a79b6dca14cdb05b5a',
family: 'FontAwesome-web',
files:
[ { url: 'example/styles/fontawesome/fontawesome-webfont.woff2',
format: 'woff2' },
{ url: 'example/styles/fontawesome/fontawesome-webfont.ttf',
format: 'truetype' } ],
style: 'normal',
weight: '400',
chars: '',
selectors:
[ '.fa',
'.fa-home:before',
'.fa-external-link:before',
'.fa-table:before',
'.fa-info:before' ] }
只排除了部分字体文件?再尝试--ignore fontawesome*, glyphicons*
,结果
{ id: '340feb78c2efa220dd893149c2ebf450',
family: 'Glyphicons Halflings',
files:
[ { url: 'example/_site/libs/bootstrap/fonts/glyphicons-halflings-regular.woff',
format: 'woff' },
{ url: 'example/_site/libs/bootstrap/fonts/glyphicons-halflings-regular.svg',
format: 'svg' } ],
chars: '',
selectors: [ '.glyphicon' ] },
{ id: '7790cf9678b2d256ac0107bea9d0834d',
family: 'FontAwesome',
files: [],
style: 'normal',
weight: 'normal',
chars: '',
selectors:
[ '.fa',
'.fa-home:before',
'.fa-external-link:before',
'.fa-table:before',
'.fa-info:before' ] },
{ id: '5a5350b6467773a79b6dca14cdb05b5a',
family: 'FontAwesome-web',
files:
[ { url: 'example/styles/fontawesome/fontawesome-webfont.woff',
format: 'woff' } ],
style: 'normal',
weight: '400',
chars: '',
selectors:
[ '.fa',
'.fa-home:before',
'.fa-external-link:before',
'.fa-table:before',
'.fa-info:before' ] } ]
一定是我用法不对……请各位指点,怎样才能把三个家族、十一个文件都排除出去~
试试使用字符串的方式?--ignore "name"
命令:
font-spider --ignore "fontawesome" --info example/*.html`
返回:
{ id: '5a5350b6467773a79b6dca14cdb05b5a',
family: 'FontAwesome-web',
files:
[ { url: 'example/styles/fontawesome/fontawesome-webfont.woff',
format: 'woff' } ],
style: 'normal',
weight: '400',
chars: '',
selectors:
[ '.fa',
'.fa-home:before',
'.fa-external-link:before',
'.fa-table:before',
'.fa-info:before' ] }
还是漏掉一个……另外字符串方式怎么指定多个匹配项呢?
使用 ,
分割即可
命令:
font-spider --ignore "fontawesome-webfont.eot,fontawesome-webfont.svg,fontawesome-webfont.ttf,fontawesome-webfont.woff,fontawesome-webfont.woff2,glyphicons-halflings-regular.eot,glyphicons-halflings-regular.svg,glyphicons-halflings-regular.ttf,glyphicons-halflings-regular.woff,glyphicons-halflings-regular.woff2" --info _site\*.html
还是不能排除所有文件:
{ id: '5c3cf3bbe37906a64d1f9e596b858bef',
family: 'Glyphicons Halflings',
files: [],
chars: '',
selectors: [ '.glyphicon' ] },
{ id: '47c35c895ca3f4b9272ceb0d4455bb16',
family: 'FontAwesome',
files: [],
style: 'normal',
weight: 'normal',
chars: '',
selectors:
[ '.fa',
'.fa-home:before',
'.fa-external-link:before',
'.fa-table:before',
'.fa-info:before' ] },
{ id: '9019f2ae4540460a0fec5969430737d2',
family: 'FontAwesome-web',
files:
[ { url: 'example/styles/fontawesome/fontawesome-webfont.woff',
format: 'woff' } ],
style: 'normal',
weight: '400',
chars: '',
selectors:
[ '.fa',
'.fa-home:before',
'.fa-external-link:before',
'.fa-table:before',
'.fa-info:before' ] }
文件名都是直接从输出复制粘贴过去的,我也是完全懵逼了。只有排除CSS文件才可以完全排除文件中定义的所有font-face,可是把不需要压缩的字体分离出来又不是那么简单……
请提供一个demo