1. 下载字蛛,全局安装
npm install font-spider -g
2. 创建一个自己的文件夹 如 test
包含下面三个目录
1. css文件夹 (font.css)
2. font文件夹 (字体1.ttf,字体2.ttf)
3. index.html
3. font.css
@font-face {
font-family: 'sf-pro-text_regular';
src: url('../font/sf-pro-text_regular.ttf') format('truetype'),
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'sf-pro-text_semibold';
src: url('../font/sf-pro-text_semibold.ttf') format('truetype'),
font-weight: normal;
font-style: normal;
}
body{
font-family:"sf-pro-text_regular";
}
.tt1{
font-family: 'sf-pro-text_regular';
font-size: 24px;
color: #333;
}
.tt2{
font-family: 'sf-pro-text_semibold';
font-size: 24px;
color: #333;
}
4. index.html
<html>
<head