An elegant font compression solution — fonttools

Original link:

Sharing a python library – fonttools, it is very convenient to deal with font files.


You need to download the python environment on your computer first, so I won’t say much about this.

Then enter on the local command line:

 pip install fonttools

font library


  1. Create a new folder locally, name it fonts , you can do whatever you want. Put the fonts you need to compress and organize in a folder, such as OPPOSans.ttf .
  2. Then create a file named word.txt , then we need to find a common font library, here I share one on github common fonts.txt , and copy the common fonts in it to the word.txt file.


 pyftsubset OPPOSans.ttf --text=$(cat word.txt) --no-hinting


Let’s take a look at the command, where OPPOSans.ttf is the font file, word.txt is the common font, we want to separate these words separately.

The names can be according to their own requirements, but they must correspond to each other.


You can enter it on the command line. After the operation is completed, you can see the font file with the word subset in the folder. The space occupied is greatly reduced, and it can be used directly.

This article is reprinted from:
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment

Your email address will not be published.