font-spider按需生成字体文件
font-spider可以全局安装,也可以单个项目内安装,使用npm runxxxx的形式。运行npm run dev后,原字体文件会被移动至.font-spider文件夹内。
·
font-spider可以全局安装,也可以单个项目内安装,使用npm run xxxx的形式
npm init -y
npm i font-spider
"dev": "font-spider ./*.html"

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
/*声明 WebFont*/
@font-face {
font-family: 'happy-font';
src:url('./zz.ttf') format('truetype');
}
.cd{font-family: 'happy-font';}
</style>
</head>
<body>
<div class="cd">字</div>
<div class="">字</div>
</body>
</html>
运行npm run dev后,原字体文件会被移动至.font-spider文件夹内

报错信息

该工具仅支持ttf(truetype)与otf(opentype)
仅支持下列2种字体格式
@font-face {
font-family: 'happy-font';
src:
url('./aaa.otf') format('opentype'),
url('./aaa.ttf') format('truetype');
}
更多推荐


所有评论(0)