Fork me on GitHub

font-spider利器对webfont网页字体压缩使用

官网

http://font-spider.org/

安装

npm install font-spider -g

使用

hyheilizhitij(汉仪黑荔枝体简)

1.通过font-face引入我们下载好的文件

@font-face{
			font-family: 'myfont';
			src:url('./fonts/HYHeiLiZhiTiJ.ttf') format('truetype');
			font-weight: normal;
			font-style: normal;
		}

2.使用自定义字体

.test{
			font-family: 'myfont';
		}

3.执行font-spider命令压缩字体
运行font-spider命令 ,页面依赖的字体将会自动压缩好,原 .ttf 字体会备份

font-spider ./index.html

压缩之前是1753.24 KB大小,压缩之后大小4.796 KB
Original size: 1753.24 KB
File fonts/HYHeiLiZhiTiJ.ttf created: 4.796 KB

4.使用效果

完整代码

<div class="test">
		账号未登录,请先登录的分身乏术地方发送
	</div>
	<style>
		@font-face{
			font-family: 'myfont';
			src:url('./fonts/HYHeiLiZhiTiJ.ttf') format('truetype');
			font-weight: normal;
			font-style: normal;
		}
		.test{
			font-family: 'myfont';
		}
	</style>

作者:fozero
声明:原创文章,转载请注明出处,谢谢!http://www.cnblogs.com/fozero/p/8953288.html
标签:css

posted @ 2018-04-26 16:21  fozero  阅读(3476)  评论(0编辑  收藏  举报