Linking Multiple Substitution Rules in FontForge
FontForge allows you to link multiple substitution rules to a single trigger through OpenType features, primarily by utilizing Contextual Chaining lookups or chaining sequential lookups. While a standard Single Substitution lookup cannot assign conflicting targets to one glyph simultaneously, you can execute multiple actions from a single trigger glyph by structuring your lookups properly within the Font Info panel. This guide explains the mechanisms available in FontForge to achieve multiple substitutions from a single trigger and the exact steps to configure them.
Understanding OpenType Substitution Architecture
In OpenType and FontForge, glyph substitution is handled by the Glyph Substitution (GSUB) table. How a single trigger interacts with multiple rules depends on your design objective:
- One-to-Many Expansion (Multiple Substitution): A
single trigger glyph expands into a sequence of multiple glyphs (e.g.,
decomposing a ligature like
ffiback intof,f, andi). - Contextual Multi-Target Substitution: A single trigger glyph condition causes multiple distinct glyph substitutions across a sequence.
- Sequential Processing: A single glyph triggers a substitution in one lookup, and the resulting glyph acts as a trigger in a subsequent lookup within the same feature.
Method 1: Applying Multiple Actions via Contextual Lookups
If you want a single context or trigger to alter multiple glyphs at once, use a Chaining Contextual Substitution (GSUB Type 6). This setup lets a single match invoke multiple nested sub-lookups.
- Navigate to Element > Font Info > Lookups.
- Select the GSUB tab and click Add Lookup.
- Set the Type to Single Substitution and create the individual substitution lookups you wish to execute (for example, sub-lookup A that changes glyph X, and sub-lookup B that changes glyph Y).
- Click Add Lookup again, but set the Type to Contextual Chaining.
- Assign your desired OpenType feature tag (such as
caltorliga). - Click Add Subtable.
- In the contextual rule editor, define your trigger sequence.
- Under the substitutions list, map the position of your trigger sequence to the different single substitution sub-lookups you created in step 3.
This configuration instructs the font engine to evaluate the single trigger and execute each linked sub-lookup sequentially.
Method 2: One-to-Many Substitution (GSUB Type 2)
If your goal is to replace a single trigger glyph with multiple distinct output glyphs, standard Single Substitution will not work. You must use a Multiple Substitution lookup.
- Go to Element > Font Info > Lookups > GSUB.
- Click Add Lookup and set the Type to Multiple Substitution.
- Select or create the appropriate feature tag (e.g.,
ccmp). - Click Add Subtable.
- Enter your single trigger glyph in the first column, and enter the space-separated sequence of target glyphs in the replacement column.
Method 3: Stacking Lookups in Feature Order
To run multiple conditional rules that affect the same trigger under varying conditions, you can stack separate lookups within the same OpenType feature:
- In the GSUB lookups list, create multiple independent lookups assigned to the same feature tag.
- Order them from top to bottom using the Move Up and Move Down buttons.
- The layout engine processes these lookups in order. If the trigger matches the first lookup, it will be substituted; the resulting glyph can immediately be evaluated by the subsequent lookup in the list.
Constraints to Keep in Mind
- Lookup Isolation: A single glyph cannot have two conflicting single substitutions within the exact same subtable. Distinct behaviors must reside in separate subtables or separate lookups.
- Evaluation Order: FontForge compiles lookups in the order they appear in the Lookups list. When chaining substitutions to a single trigger, ensure dependent lookups appear after the lookup that produces the target glyph.