User Guide
Making OpenType Fonts
671
Example 2. Matching a beginning-of-word boundary:
ignore substitute @LETTER f' i';
substitute f' i' by f_i.begin;
The example above shows how a ligature may be substituted at a word
boundary. @LETTER must be defined to include all glyphs considered to
be part of a word. The substitute statement will get applied only if the
sequence doesn't match "@LETTER f i"; i.e. only at the beginning of a
word.
Example 3. Matching a whole word boundary:
ignore substitute @LETTER a' n' d', a' n' d' @LETTER;
substitute a' n' d' by a_n_d;
In this example, the a_n_d ligature will apply only if the sequence "a n d"
is neither preceded nor succeeded by a @LETTER.
Example 4. This shows a specification for the contextual swashes feature:
feature cswh {
# --- Glyph classes used in this feature:
@BEGINNINGS = [A-N P-Z Th m];
@BEGINNINGS_SWASH = [A.swash-N.swash P.swash-Z.swash T_h.swash m.begin];
@ENDINGS = [a e z];
@ENDINGS_SWASH = [a.end e.end z.end];
# --- Beginning-of-word swashes:
ignore substitute @LETTER @BEGINNINGS';
substitute @BEGINNINGS' by @BEGINNINGS_SWASH;
# --- End-of-word swashes:
ignore substitute @ENDINGS' @LETTER;
substitute @ENDINGS' by @ENDINGS_SWASH;
} cswh;
If a feature targets only glyphs at the beginning or ending of a word, such
as the 'init' and 'fina' features, then the application could be made
responsible for detecting the word boundary; the feature itself would be
simply defined as the appropriate substitutions without regard for word
boundary.