生成指定文字的字体


生成指定文字的字体(减少字体文件大小)

第二步:下载font-spider

npm install font-spider -g

第二步:新建一个html文件(所需处理字体)

<html>
<head>
 <!-- 引入css文件 -->
  <link rel="stylesheet" href="font.css">
</head>
<body>
  <!-- 需要转换的文字放在标签内,只能压缩静态字体 -->
  <p class="ttf">1234567890abcdefghijklnmopqistuvwsyzTtinitFONT</p>
</body>
</html>

第三步:新建一个css文件(处理的ttf文件)

@font-face {
  font-family: 'sf-pro-text_regular';
  /* src引入需要精简的ttf字体文件 */
  src: url('./douyu.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}
body {
  font-family: "sf-pro-text_regular";
}
.ttf {
  font-family: 'sf-pro-text_regular';
}

第四步:在当前目录下执行命令

font-spider ./*.html

  目录