There are two types of contextual positioning modes: Contextual Positioning
and Chained Contextual Positioning. In the simplest form of the first you
may specify a list glyphs and specify repositioning to occur if that sequence
is matched. For example you might specify (in English)
5 t h
and if that sequence were found raise the "t" and "h" to 5th.
You can also specify classes of glyphs so you could say something like:
[0-9] t h
to raise "t" and "h" after any digit.
After applying this lookup, a word processor will skip over the three glyphs matched by the pattern, at least it will in a simple "Contextual Positioning" lookup. The "Chained Contextual Positioning" lookup is a bit more general and allows you to divide the pattern into three parts: A part before the current glyph (called backtracking), a part including the current glyph, and a part after the current glyph (called lookahead). Positioning changes may only be made to the part including the current glyph, and the word processor will advance by the number of glyphs in that subset of the pattern.
Substitutions come in three types. The first two are similar to the two types for positioning, the third is designed to handle a very specific case of arabic typography and is applied backwards.
Suppose you had a script font where most letters join at the base line, but
after some letters (b,o,v,w) the join is near the x-height, so a special
version of each lower case letter needs to be created designed for a left
side join near the x-height. You would want to be able to say:
[bovw] [a-z]
Note that this just specifies the cases in which the substitution may be
applied. It does not specify the substitution itself, that is done in a separate
lookup.
You may pull down an example script font with this substitution from FormalScript.tgz, this example is worked out in detail in the tutorial.
For more information on contextual features see Adobe's Docs:
In some cases a contextual or chaining contextual substitution can be converted into one of Apple's contextual glyph substitution subtables. See the page on Apple Advanced Typography for more information as to when and caveats about how.
Before you can edit one of these features you must create it from the Element->Font Info->Contextual dialog.
Except for the reverse chaining features, any of these may come in one of three formats.
The simplest format is a list of glyphs. You may specify
several glyph sequences in a single feature. So the script example above
could be specified (quite inefficiently) by 4*26 lines like:
b a
b b
...
o a
...
The next format allows you to specify a list of
classes. In the script example we would define 2
classes:
[bovw]
[ac-np-ux-z]
and define two patterns as:
class1 [class2]
class1 [class1]
The third format is the most general and allows you to specify your pattern
by a separate list of glyphs for each glyph
position:
[bovw] [a-z]
This display shows a list whose entries are coverage tables -- that is lists of glyphs. A match occurs if the current glyph matches one of the glyphs named in the current coverage table.
In the example at right there is only a single coverage table here (but there could be more).
In a Chaining Contextual feature it is also possible to specify a list of coverage tables to match glyphs before the current glyph, and another list to match glyphs after.
This feature does not directly describe how transformations are to happen to the glyphs, instead it invokes a list of nested lookups that are to be applied to specific positions in the match string (positions in the backtrack and lookahead lists may not be transformed).
In the example at right, the lookup 'high' will be applied to any glyph that matches the coverage table at the top of the list. Again the buttons under the sequence lookup list allow you to add, change, remove or reorder these transformations. (And yes, the order the transformations are applied can matter in complex situations).
You can change a lookup by clicking on it, this will produce a pull down menu of all lookups that can be applied. You can change the position by editing it.
You can add a new entry by pressing the <New> button, and then selecting a lookup.
You can change a coverage table by editing it. You may enter either glyph
names or unicode characters (which will be converted to a glyph name -- a
few characters which have special meaning: space, right parenthesis, asterix;
must have their names typed in full). If you click on the little box on the
right you will get a dialog containing a font view. In this view you may
select glyphs to your heart's content, when you press OK these glyphs become
your table.
This format allows you to specify several glyph lists to match. In the example at right the string "A,B,C" will be matched in the glyphs before the current glyph, then "D E" starting at the current location, and finally "F G H" after them. If everything matched then the lookup "Smallcaps" will be applied to location 0 (in this case "D") , and "superscript" to location 1 (here, "E").
The order is significant, word processors will stop at the first match they
find so in the following pattern strings:
b a
b a f
the second entry would never be matched because "b a" would be applied first.
While:
b a f
b a
would apply match "b a f" when an "f" was present, and "b a"
otherwise.
The text field may be manipulated as above. However here we are specifying a string of glyphs each of which must be matched, rather than a class of glyphs any of which could match. So in the example at right, "DE" would match, but "E" would not.
As above a set of lookups can be applied after the match occurs.
When specifying a class match, you must specify at least one set of glyph classes. (you may also specify separate sets of classes for the backtrack and lookahead lists, or you use the same set for everything). You must also specify a list of patterns where each pattern is a list of numbers and each number is the index of the class into the class list.
Every set of classes has a magic class at index 0 which matches whatever
glyphs are not explicitly mentioned in another class. FontForge displays
this by calling it "{Everything Else}". You may not delete, edit nor reorder
this class. Other classes are just unordered lists of glyph names (rather
like coverage tables above), however any specific glyph may belong to at
most one class at a time (whereas a glyph may occur in as many coverage tables
as desired).
Once you have set up your classes, you may then edit the patterns you want to match. To remind you of what your classes are, FontForge displays the class list underneath the pattern. Clicking on a class will insert that class's index into the pattern.
Finally you must set the nested lookups. This is exactly the same as previous
sequence / lookup settings.