TYPO Labs: The Power of Python

In this splitted talk, Just van Rossum introduced the technology of fontTools with TTX, its history, its development and finally its rescue: Behdad Esfahbod.

TTX is an integrated tool for the FontTools Python module. You can programmatically manipulate font files without touching them with an editor. It’s made possible by conversion of font formats to a Python object and from Python to XML based TTX and vice versa. It also supports all common formats.

You can access the OpenType tables like GPOS (Glyph Positioning, e.g. responsible for cursive attachment) and GSUB (Glyph Substitution, e.g. for Arabic glyph variations) and control kerning, positioning, rotation, cursive joining etc. Imagine your font gets hinted by somebody else for a lot of money: You don’t want to monkey with the finished details and corrupt the whole work.


TYPO-Berlin-2016-05-11-Norman-Posselt-0046Just van Rossum presenting TTX

But you can! Leave your angst behind and unlock the magic of python:

• Compress your font file 3(!) times smaller with the CFF (Compact Font Format) table subroutinizer Compreffor. It gives you another 10% over Adobe’s implementation. You might want to “freeze” true smallcaps, oldstyle numerals or Bulgarian localized forms in apps that don’t support OpenType Layout features (such as Office) with pyftfeatfreeze.

• Also conveniently make use of TTX for debugging. For example let’s print specific GSUB/GPOS features or even access them in any weird way that comes into your dark mind, like kerning, accent positioning, cursive joining, ligatures, arabic forms, vertical rotation, indic glyph rearrangement.

• Run checks on source files in UFO (Unified Font Object), SFD (Spline Font Database) or TTX formats and build them via FontForge or AFDKO (Adobe Font Development Kit for OpenType) into OTF and TTF files (plus the files needed for hosting in Google Fonts).

• Calculate geometrical glyph statistics with symfont.py. And, mentioning Behdads favorite, write a Multiple Master GX font out of several master fonts with interpolate.py. Compress and decompress WOFF2 fonts. Change Adobe glyph names with AGL and AGLFN.

• Make arabic glyph names out of glyphs compatible to FontLab (nobody did that yet, but it would be really cool). Create new pens, which can be used to render outlines to the screen, but also to construct new outlines.

TYPO-Berlin-2016-05-11-Norman-Posselt-0054


Who got the idea to create the framework for such great possibilities? Just “I need to control what comes out of it”. Well, he wasn’t the only one: there were (and are) Peter van Blokland, Werner Lemberg (who also presented his ace hinting Library ttfautohint—Behdad also had his fingers in the pie here by the way), Adam Twardoch, Read Roberts (Adobe) and Paul Wise (for maintenance and release).

As young and wild as they were in the nineties, someday there was no need for so many new features any more. The project turned old. Suddenly the whole way of maintenance changed. GitHub came up, Python 3 was knocking on the door and WOFF was barking in the backyard.

“Should we use tabs or spaces?”

To the rescue: Behdad Esfahbod from Google Fonts became partner in crime. The Noto project needed a GLYPHS to UFO converter, the open source font format. Because Georg Seifert was “more interested in important other stuff” at that moment, Behdad, then UFO newbie, started to play with the RoboFab Python library. After an amusing period of forking each others codes, finally Google and “these Dutch people” found a basis. Behdad emailed Erik van Blokland and asked to finally meet—because he would coincidently be in Amsterdam visiting Bahman Eslami—which was a lie. Fortunately Erik responded with a smiley face.


TYPO-Berlin-2016-05-11-Norman-Posselt-0050Partner in crime Behdad Esfahbod took over Part 2 of the talk

The first task of the communication between the FontTools team and Behdad was: “Should we use tabs or spaces?”. Cosimo Lupo and Sascha Brawer joined the team. Together they built a new big platform and FontTools was back on track.

Color font support came up too. Similar to Erik van Bloklands MutatorMath, through varLib the user can make use of run-time interpolation in GX variation fonts. Also The cu2qu Library (e.g. fonts_to_quadratic) was developed. A great way to convert cubic beziers to quadratics. There is other stuff on the to do list like integrating ttfautohint into fontmake, which compiles fonts from various sources (GLYPHS, UFO) into binaries (OTF, TTF).

You can access and follow all the libraries via GitHub. Also take part on the discussion via the mailing list. The developers decided to hold back the new release of FontTools until the end of TYPO Labs 2016. What better place would there be to discuss the latest developments than the 1st TYPO Labs?

The next release is planned by the end of TYPO Berlin 2016.

Stay tuned:

☞ https://github.com/behdad/fonttools
☞ https://github.com/googlei18n/cu2qu
☞ https://github.com/googlei18n/compreffor
☞ https://github.com/googlei18n/ufo2ft
☞ https://github.com/googlei18n/fontmake


Written by Rik Watkinson
Photographs by Norman Posselt / Monotype