npm install font-spider -g
全局安装
新建font.html和 reset.css
将所需要的全部字体放入html并引入reset.css
reset.css(注意相对路径)
/*声明 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;}/*使用选择器指定字体*/.home h1, .demo > .test {font-family: 'pinghei';}
- @font-face 中的 src 定义的 .ttf 文件必须存在,其余的格式将由工具自动生成
- 开发阶段请使用相对路径的 CSS 与 WebFont
//终端输入
font-spider ./font.html (后面.html填写你创建的页面)
最后.font-spider中生成新字体
