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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM