Giving a Handwriting Font More Variation via OpenType
I recently tried to make a font of my own handwriting less obviously a font by adding OpenType rules that swap glyphs based on context. I’m not thrilled with the output—it lands in a bit of an uncanny valley—but the process was easy and fun, so I’m documenting it here.
Starting point: a font of my handwriting
I created a font of my handwriting a few years ago for my zines, using the iFontMaker app. The pitch—“make a handmade typeface in less than 5 minutes with just your fingers”—is mostly accurate. I spent maybe 15 minutes, and I used an Apple Pencil (which I suspect offers better accuracy than a bare finger). For $7.99 on an iPad, it’s a pleasant way to produce a TTF of your own writing. That process yields two fonts: a regular one and a handheld-style “monospace” variant. The latter isn’t truly monospace; I haven’t worked out how to make one in iFontMaker.
The tell that it’s a font rather than handwriting is easy to spot when the same letter appears twice in a row—for instance, the two Ts in “HTTP” are identical. My goal was to add subtle variation by swapping in alternate letterforms depending on neighboring characters.
A talk about OpenType leads to the core trick
The idea came from Tristan Hume’s !!Con 2020 talk, which uses OpenType shaping to place commas in large numbers automatically. The live demo shows the payoff quickly; the blog post and GitHub repo fill in the implementation details.
I knew almost nothing about OpenType before this. What I learned is that you can write very simple feature rules to alter glyph rendering, no deep font knowledge required. Suppose you want an alternate a whenever it precedes a b. The feature file line:
sub a' b by other_a;
means: if an a glyph is immediately before a b, replace the a with the glyph other_a. So ab can look different from ac. That’s not stochastic like real handwriting, but it introduces some variety.
The most useful reference I found was the OpenType Feature File Specification from Adobe, which includes plenty of examples—like replacing the sequence ffi with a ligature.
Applying the rules with fonttools
The Python library fonttools makes it trivial to inject new OpenType rules. With just a few lines you can apply a given feature file (rules.fea) to an existing TTF:
from fontTools.ttLib import TTFont
from fontTools.feaLib.builder import addOpenTypeFeatures
ft_font = TTFont('input.ttf')
addOpenTypeFeatures(ft_font, 'rules.fea', tables=['GSUB'])
ft_font.save('output.ttf')
Some fonttools CLI utilities also came in handy. The ttx tool converts a TTF into an XML representation. I needed to rename some glyphs, so I converted the font to XML, used sed for the renames, then converted it back to TTF. Meanwhile, fonttools merge let me combine my three handwriting fonts into one so all the needed alternate glyphs would be available in a single file.
The outcome
I put the rough 33-line proof of concept—spread across run.sh and combine.py—in a repo creatively named font-mixer.
Comparing the old and new fonts side by side, the tweaked version does show a bit more variation, but it still doesn’t read as convincing handwriting. Compared with what I actually write by hand:
it feels like the text is deliberately trying to look organic and failing slightly. The result might be better if I’d spent more care building the two other handwriting variants that got mixed in.
The takeaway
What I found genuinely neat is how easy it is to add OpenType features that change font behavior—you could trivially make a font swap every occurrence of “the” to “teh” if you ever wanted typos everywhere. As for getting a font to more authentically mimic handwriting, I’m still not there; I’ve gone back to the unmodified original font and I’m happy with that.



