字体⽂件使⽤及压缩
1.字体⽂件可以获取任意⼀类,然后去⽹站⽣成兼容不同浏览器的⽂件。⼀般情况下,在⽹上能搜到字体的类型⽂件:ttf。
2.字体⽂件太⼤,⼀般选择⽤字蛛去压缩字体⽂件。
安装命令:
npm install font-spider -g
在 CSS 中使⽤ WebFont:
/*声明 WebFont*/
@font-face {
svg文件怎么生成
font-family: 'pinghei';
src: url('../');
src:
url('../?#font-spider') format('embedded-opentype'),
url('../font/pinghei.woff') format('woff'),
url('../f') format('truetype'),
url('../font/pinghei.svg') format('svg');
font-weight: normal;
font-style: normal;
}
/*使⽤选择器指定字体*/
.home h1, .demo > .test {
font-family: 'pinghei';
}
1. @font-face 中的 src 定义的 .ttf ⽂件必须存在,其余的格式将由⼯具⾃动⽣成
2. 开发阶段请使⽤相对路径的 CSS 与 WebFont
运⾏:
font-spider ./demo/*.html
使⽤注意:⽂件⽬录这样创建: