The context and chaining context lookups are meta-lookups: they specify a certain context, in which other lookups may operate at different positions. The sub-lookups may be either substitution or positioning lookups.
lookup abcToxx {
context (q) a b c (r);
sub 0 ab_to_x;
sub 1 c_to_x;
}
lookup ab_to_x {
sub a b -> x;
}
lookup c_to_x {
sub c -> x;
}
This example shows a (nonsense) lookup that changes the sequence "qabcr" into "qxxr". It works as follows:
context (q) a b c (r)
bit;
in this context, the sequence "abc" is the input sequence.
The "q" sequence is called the backtrack sequence.
The "r" sequence is called the lookahead sequence.
These may be longer than one glyph, and they may contain glyph lists.
That was a nice example showing how things work exactly, but here is a more useful example. When the glyph "i" is followed by a mark above, the dot above the i is removed and the mark is placed over the "dotlessi" glyph. This may be done be replacing "i" by "dotlessi" whenever it is followed by a mark above.
lookup dotlessI {
ignore mark except @marksAbove;
context [i j] (@marksAbove);
sub 0 iToDotlessI;
}
lookup iToDotlessI {
sub i -> dotlessi;
sub j -> dotlessj;
}
The context that is matched here is either i or j, followed by a combining mark above. If such a sequence is found, at position 0 (the first position of the input sequence) a lookup is applied that changes "i" into "dotlessi" and "j" into "dotlessj".
Note: OTComp will generate a contextual lookup when you specify no glyphs for the backtrack and lookahead sequences. If you do, a chaining contextual lookup will be generated.