且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从字体文件中删除字符?

更新时间:2023-12-04 20:26:46

我找到的最简单的方法是使用pyftsubset工具="noreferrer">字体工具.这是一个示例:

The easiest method I found is to use pyftsubset tool from FontTools. Here's an example:

$ pyftsubset NotoSans-Regular.ttf \
      --unicodes=U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116 \
      --output-file=NotoSans-Regular.cyrillic.woff2 \
      --flavor=woff2

注意:woff2输出需要 Brotli .

我围绕它编写了一个简单的脚本,该脚本可自动执行整个过程,包括在分割字体文件后生成CSS文件.您可以在这里找到它: https://github.com/johncf/ttf2web

I wrote a simple script around it which automates the whole process including generation of a CSS file after splitting the font file. You may find it here: https://github.com/johncf/ttf2web