Tutorial for the implementation of the contextual substitution feature in an otf font

The following is incomprehensible if not read with a browser that provides proper support for Opentype.


Many of us discovered FontForge with wonder, but we certainly have much less worked on the mechanism of contextual substitution. However, it is a significant improvement and a font that does not implement this feature seems obsolete. The problem is that you can not find a comprehensive manual on the web: I mostly learned by trial.

The otfpoc font, which is being used for writing this text, serves both as a demonstration and a model..

Contextual substitutions are implemented in otfpoc to connect lowercase letters of the Latin alphabet as it should be. For example if a letter c is followed by c then they are processed to connect like this: cccc.

If you wish, I can guide you to do the same with your own font.

Included within otfpoc font structure is a table of its glyph substitutions, the "GSUB Opentype Layout table", that can be reused to prepare your connected typeface. You may substitute your own glyphs in my otfpoc FontForge source for testing.

1st step: the connection pattern

The connection is adding to glyphs overlapping links, so as to form a continuous line. This must be done in a consistent manner, according to a model. In fact, it takes at least two models, one for the connecting elements at the bottom (garlands) and one for the connecting elements at the top (arcades). Could further complicate but you'll see, it's bad enough as it brainer!

I chose to place the overlap before the width of the first glyph. This is a trick to make some letters contain in their basic variant the right connection pattern. Thus only the second glyph must be changed and the number of variants is decreased. You may prefer to connect the glyphs after the glyph width, but in all cases it is essential that the overlap is at least 40 points and is done entirely on one side or the other to avoid hinting mechanisms cause shifts to the display.

Bottom connection
Here is a connection in the font otfpoc. The variant of the letter "c" is connected to the glyph uniE028.

In the font otfpoc the low overlap is always positioned in a circle in one place. Note that the second glyph overflows left but the first glyph remains before its width.

The letters o, v and w are attached at the top, which requires a second overlap model.

Top connection
A top connection.

Design this overlap in a drawing suitable for your glyphs. Place it so that it gives you maximum latitudes even if you have to define unnaturally the width.

2nd step: drawing variants

At this stage, I suggest you do a test: open with FontForge the otfpoc source and put in it your own glyphs.

1) Import glyphs with a height of 1000:

2) Redraw your letters "a d f h k l m n r t u" to incorporate the right side of your bottom connecting model.

3) Switch to the private area to put your glyphs variants redesigned with the connections that go. Their name consists of the name of the base glyph concatenated with a suffix as follows:

Variants in the private area.

4) Generate the Opentype font (CFF) and use the print function in FontForge or an html page with Iceweasel to enjoy the result. I'll let you go but you'll need to adapt your GSUB layout table so a last explanation is required.

The GSUB OpenType Layout table

In FontForge, go to Element->Font Info->Lookups. There are two tabs, one for the GSUB layout table and one for the GPOS layout table. One that concerns us is GSUB. In the GSUB table there are several lookups

Those defined in the otfpoc font are:


Open the subtable "calt 1st pass-1" of the first lookup. You will find, for example, the letter c in Class 1. The first rule is "1 @<Substitutions 0x1> 1 @<Substitutions 1x0>". The lookup "Substitutions 0x1" transforms the letter c into its variant c.0x1 and the lookup "Substitutions 1x0" transforms the letter c into its variant c.1x0 .

Ultimately this lookup transforms the sequence of glyphs "c c c c" to "c.0x1 c.1x0 c.0x1 c.1x0".

Lookup indice 0
The subtable of the first lookup

Lookups apply on the outcomes of previous lookups.

Now let see the second lookup named "calt 2nd pass-1".

Shortening, a rule is:

After executing the two lookups in sequence our glyphs becomes "c.0x1 c.1x1 c.1x1 c.1x0" ie the expected result, cccc.

Lookup indice 1
The subtable of the second lookup



Copyright Philippe Cochy 2012. Reproduction prohibited without permission.