# 字蛛--引入特定中文字体 ,一个中文字体压缩器 **Repository Path**: HuanRi/fontSpider ## Basic Information - **Project Name**: 字蛛--引入特定中文字体 ,一个中文字体压缩器 - **Description**: 字蛛是一个中文字体压缩器 让网页自由引入中文字体成为可能 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-11-23 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # buildfont # 安装 npm install font-spider -g # 使用 ## 首先需要在css文件中引入WebFont /*声明 WebFont*/ @font-face { font-family: 'pinghei'; src: url('../font/pinghei.eot'); src: url('../font/pinghei.eot?#font-spider') format('embedded-opentype'), url('../font/pinghei.woff') format('woff'), url('../font/pinghei.ttf') format('truetype'), url('../font/pinghei.svg') format('svg'); font-weight: normal; font-style: normal; } ## 然后使用选择器使用WebFont /*使用选择器指定字体*/ .home h1, .demo > .test { font-family: 'pinghei'; } ## 运行font-spider命令 font-spider ./demo/demo.html 值得注意的是,这里可以使用通配符*来匹配所有的html文件 font-spider ./demo/*.html 也可以同时压缩不同文件夹内的html文件,文件夹之间插入空格 font-spider ./demo/*.html ./demo/pages/index.html 至此,font-spider会将原本的字体文件压缩到很小,原本的字体文件将会备份到元目录下的font-spider文件夹内 # 创建固定文字 字体 font-spider ./font.html