1.将想要使用的文字放在标签中,@font-face定义好要使用的字体,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
@font-face {
/* 自己定义一个名称 */
font-family: "dinAlternate";
/* 字体的路径 */
src: url("./din.ttf");
}
p{
/* 自定义的字体名称 */
font-family: "dinAlternate";
}
</style>
<body>
<p>1234567890.-+</p>
</body>
</html>
2. 全局安装font-spider npm包:
sudo cnpm i font-spider -g
3. 使用font-spider包对字体进行编译,找到刚才写的html文件,对其进行编译
font-spider index.html