Let's say I have a long text:

Latebrae agente praefuit imperator nec praefuit ducens insidiarum sunt insidiarum emensis fatorum ubi milites rebus Noricorum viam sorte rebus suis emensis tristissima itaque et vita suis Noricorum erat ulla repente quos sunt spoliari reseratae iumentorum qua fatorum viam apparuit latebrae omnes elegerat Barbatio imperator sub spoliari spoliari eo iumentorum nec sunt sub itaque sunt tristissima vita itineribus latebrae emensis imperio ulla sorte eo et omnes nec permutatione Barbatio praemiis suis ulla ubi praefuit latebrae itineribus spoliari Apodemio latebrae oppigneratos ulla ubi itineribus apparuit ubi cum eo comes certus fatorum elegerat sorte itaque praemiis Apodemio et Noricorum comes latebrae imperator omnes.

How I can subset (strip) a TrueType font (.ttf file), so it would contain only the glyphs of the precedent text while keeping every font features (vertical kerning ; hinting …)?


You would need pyftsubset. It's a tool that is part of my fork of fonttools. Here's the manual for it:


Note that pyftsubset is not part of the upstream fonttools, so you won't get it using apt-get for example. Here is how to do what you need:

$ git clone http://github.com/behdad/fonttools
$ fonttools/Tools/pyftsubset inputfont.ttf --text="Latebrae agente..."

This way you get a subset font saved to inputfont.ttf.subset. You can give the text to the tool from a file using --text-file. There are many other options to the tool, try --help.

  • It is not provided with the Debian apt-get version, but it can OK. Oct 29 '14 at 21:49
  • @user2284570 One year on, Debian added version 3.0 (behdad's version); you can find it in the Sid and Stretch repositories. If you're using Jessie, you can just download the .deb file and manually install it: packages.debian.org/stretch/all/fonttools/download Mar 2 '16 at 1:15
  • @ChrisJester-Young : not really a problem, after using his tool I saw all vertical kerning tables were gone. So I spent an entire day doing it manually. Mar 2 '16 at 1:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.