Skip to main content

FontCreator Tutorials

Variable Contextual Kerning – Triplets

written by Erwin Denissen, published November 21, 2022

I am sure you’ve been there, all side-bearings and kerning pairs look great, but while further looking at long lists of text to verify all kerning is looking great, you spot some more issues.

This time adjusting a single kern pair won’t do as the problem relates to more than a pair of characters. It just doesn’t look right with specific surrounding characters (L’Amour). There are several solutions to overcome collisions or incorrect spacing between a range of characters. One of them is contextual kerning. Regular kerning remains, so we go from there to add additional spacing.

We use the OpenType Designer to add both a pair adjustment (PairAdjTriplet) and a chained context positioning (TripletAdj) lookup.

Since the contextual kerning adds to the regular kerning, we add it to the existing kern feature, so people can decide to enable the whole set of kerning or not.

This is the complete feature code, containing the original kerning as well as the newly added contextual kerning:

languagesystem latn dflt; # Latin default

lookup PairAdjTriplet { # GPOS lookup type PairAdjustment
pos quoteright A <(wght=72:100 wght=170:100 wght=16:200) (wght=170:0) (wght=72:120 wght=170:80 wght=16:250) (wght=170:0)>;
} PairAdjTriplet;

feature kern { # Kerning
lookup PairAdj { # GPOS lookup type PairAdjustment
pos L quoteright (wght=72:-260 wght=16:-220 wght=170:-260);
pos quoteright A (wght=72:-90 wght=16:-130 wght=170:-40);
} PairAdj;
lookup TripletAdj { # GPOS lookup type ChainedContextPositioning
pos L quoteright' lookup PairAdjTriplet A';
} TripletAdj;
} kern;

And here is the end result:

Credits: the font used in this tutorial is Kantumruy Pro – variable font by Tep Sovichet –

Note: The used variable feature code is currently not part of the official AFDKO, but they are working on it.