Lookup Type 3 — Alternate Substitution
Alternate Substitution is a GSUB rule that replaces a single glyph with one of the glyphs listed as candidates.
sub zero from [zero.zero zero.lf];Rules are written inside a feature block. Used in the aalt feature, for example:
feature aalt { sub zero from [zero.zero zero.lf];} aalt;Syntax
Section titled “Syntax”sub <glyph> from <glyphclass>;<glyph>— the single glyph being replaced.<glyphclass>— the glyph class listing the replacement candidates.
The rule only decides the set of candidates. Which candidate is used is not decided by the rule — the application applying the feature chooses it.
Shorthand
Section titled “Shorthand”sub is the short form of substitute. These two rules are the same:
substitute zero from [zero.zero zero.lf];sub zero from [zero.zero zero.lf];How the lookup type is determined
Section titled “How the lookup type is determined”The syntax is similar to Lookup Type 1, but there is no need to state the Lookup Type. The compiler determines it from the shape of the rule.
# a single glyph → one candidate from the class = Alternate Substitution (Lookup Type 3)sub ampersand from [ampersand.1 ampersand.2 ampersand.3];# every glyph in the class → the same single glyph = Single Substitution (Lookup Type 1)sub [ampersand.1 ampersand.2 ampersand.3] by ampersand;Try it
Section titled “Try it”The workbench font has two variants of zero (a slashed zero.zero and a lining zero.lf). This preview enables the feature and applies the first glyph in the candidate class, so swapping the order of zero.zero and zero.lf changes which zero is shown while the shape of the rule stays the same.
Features that use this lookup type
Section titled “Features that use this lookup type”The OpenType specification recommends implementing the following features with this lookup type.
aalt— Access All Alternates. Gives access to all variants of a selected character.salt— Stylistic Alternates. Replaces the default form with a variant chosen for aesthetic effect.cv01–cv99— Character Variants. Lets the user choose a variant per character, independent of other characters.swsh— Swash. Replaces the default form with the corresponding swash form.nalt— Alternate Annotation Forms. Replaces the default form with annotation forms such as circled or parenthesized forms.jp78— JIS78 Forms. Replaces JIS90 forms with JIS78 forms.rand— Randomize. Uses multiple variants to reproduce the irregularity and variety of handwriting.
For salt, swsh, nalt, and jp78, one-to-one substitutions are written with Lookup Type 1, and substitutions that need to choose among several candidates are written with this lookup type. Font developers can either combine the two lookup types or write everything with Lookup Type 3.