一、网上下载'ttf'字体
二、在项目中使用
<!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>
<style>
@font-face {
font-family: 'homeFont';
src: url('./siyuan.ttf');
font-weight: normal;
font-style: normal;
}
p {
font-family: 'homeFont';
}
</style>
</head>
<body>
<p>好</p>
</body>
</html>
三、下载压缩字体依赖
npm install font-spider -g
# 查看版本号
font-spider -V
四、如果是vue中字体需要压缩,需要自己在外新建一个文件夹来存放压缩字体。
打开终端,输入命令
font-spider index.html
五、复制.font-splider中字体到vue项目进行替换
,Copyright © 2008-2022 秒下下载站
m.down10s.com .All Rights Reserved