• Stars
    star
    4,975
  • Rank 8,127 (Top 0.2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Smart webfont compression and format conversion tool

font-spider

NPM Version NPM Downloads Node.js Version Build Status

[简体中文] | [English] | [日本語]

Font-spider is a compress tool for WebFont which can analyze your web-page intelligently to find the fonts out which have been used and then compress them.

字蛛是一个智能 WebFont 压缩工具,它能自动分析出页面使用的 WebFont 并进行按需压缩。

フォント・スパイダー(font-spider)は、Webフォントを圧縮するためのスマートなツールです,Webページに使用されるWebフォントを分析し、必要に応じて圧縮することができます。


font-spider

Feature

  1. Font subsetter: Our tool is based on HTML and CSS analysis and completely running in local so that.
  2. Font converter: Support woff2, woff, eot, svg font format generation.

Install

npm install font-spider -g

Use

step one: code CSS

@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';
}

Attention: the ".ttf" file must be existed which is referred in src property of @font-face, and our font-spider will automatically generate other formats of font.

step two: compress WebFont by using font-spider

font-spider [options] <htmlFile1 htmlFile2 ...>

htmlFiles

One or more web-page addresses which support the http form.

Example:

font-spider dest/news.html dest/index.html dest/about.html

options

Usage: font-spider [options] <htmlFile ...>

Options:

  -h, --help                    output usage information
  -V, --version                 output the version number
  --info                        show only webfont information
  --ignore <pattern>            ignore the files
  --map <remotePath,localPath>  mapping the remote path to the local
  --no-backup                   do not back up fonts
  --debug                       enable debug mode

sample of parameters usage

Use the wildcard character to compress the WebFont of several HTML file:

font-spider dest/*.html

--info Show the WebFont that has been used on the website:

font-spider --info http://fontawesome.io

--ignore Ignore the file:

font-spider --ignore "icon\\.css$" dest/*.html

--map This parameter will map the WebFont of online page to local and then compress it (the local path must be an absolute path):

font-spider --map "http://font-spider.org/font,/Website/font" http://font-spider.org/index.html

Build plugins

API

See:API.md

Limitations

  • Only the constant texts and styles are supported, but not the dynamic elements and styles which is inserted by javascript.
  • The ".otf" format fonts should be transfered to ".ttf" format firstly, so that we can start our compressing work.
  • Only the HTML and CSS files which is encoded by utf-8 are supported.

[Link] 让 font-spider 支持 js 动态内容

[AD] 前端招聘:在海边写代码

More Repositories

1

art-template

High performance JavaScript templating engine
JavaScript
9,847
star
2

artDialog

经典的网页对话框组件
JavaScript
3,134
star
3

tmodjs

前端模板外置解决方案
JavaScript
668
star
4

pinyin-engine

JavaScript 拼音匹配引擎
HTML
462
star
5

gulp-font-spider

字蛛 gulp 插件
JavaScript
190
star
6

angular-popups

基于Angularjs的浮层组件
HTML
117
star
7

popupjs

W3C HTML5 Dialog Plus
JavaScript
112
star
8

art-template-loader

art-template loader for webpack
JavaScript
106
star
9

node2bat

基于JScript的迷你NodeJS运行时
Shell
57
star
10

angular-drag

基于Angularjs的拖拽指令
HTML
55
star
11

browser-x

一个基于 NodeJS 实现的虚拟浏览器
JavaScript
49
star
12

jsonp-sandbox

jsonp sandbox
JavaScript
49
star
13

express-art-template

art-template for express
JavaScript
43
star
14

koa-art-template

a koa view render middleware, support all feature of art-template
JavaScript
41
star
15

grunt-font-spider

字蛛 grunt 插件
JavaScript
35
star
16

include-file

HTML 静态文件局部模板批量更新工具
HTML
23
star
17

blog

18
star
18

art-template-docs

art-template document
JavaScript
12
star
19

grunt-unwrap

将 CMD 模块转换成不依赖加载器的工具
JavaScript
9
star
20

vs-code-github-markdown-theme

vs code: markdown theme
CSS
7
star
21

koa-gitlab

simple gitlab auth middleware for koa
JavaScript
4
star
22

devtools-watcher

DevTools Watcher
HTML
3
star
23

sublime-art

art-template syntax definition for Sublime Text 3
3
star
24

file-cache-webpack-plugin

Webpack plugin that persists the compiler cache to the file system
JavaScript
2
star
25

free-fonts

收录字蛛可以压缩并且免费的字体
2
star
26

amd-to-commonjs

JavaScript
1
star
27

ISPAdBlock

ISP 广告拦截器
1
star
28

hexo-renderer-art

art-template renderer for Hexo
JavaScript
1
star