Editing Fonts > Format > OpenType Layout Features > Script Editor > Script Syntax > Sub

OpenType Layout Features - Sub

<< Click to Display Table of Contents >>

Navigation:  Editing Fonts > Format > OpenType Layout Features > Script Editor > Script Syntax >

OpenType Layout Features - Sub

The sub keyword declares a substitute. As explained in the supported substitution types section there are several substitution types. Substitutions can only be declared in lookups. It is not possible to declare a substitution directly in a feature. Each lookup can only have one type of substitution; this means that if you want to use several substitution types in a single feature, multiple lookups have to be declared.

Declaring Single (Type 1) substitutions

lookup MyLookupTable {

 sub A -> a.smcp;

}

 

Declaring Multiple (Type 2) substitutions

lookup MyLookupTable {

 sub ffi -> f f i;

}

 

Declaring Alternate (Type 3) substitutions

lookup MyLookupTable {

 sub asterisk -> [asterisk asteriskmath uni2051 uni2042 uni203B uni273B];

}

 

Declaring Ligature (Type 4) substitutions

lookup MyLookupTable {

 sub f f i -> ffi;

}

 

Declaring Chained Context (Type 6) substitutions

lookup MyLookupTable {

 context (@<backtrackclasses>) @<inputclasses (@<lookaheadclasses);

 sub 0 <substitution table>;

}

 

IMPORTANT: The order in which substitute declarations appear is also the way they are processed by applications supporting OpenType Layout Features. This means that in the case of ligatures:

lookup MyLookupTable {

 sub f i -> fi;

 sub f f i -> ffi;

}

 

is not the same as:

lookup MyLookupTable {

 sub f f i -> ffi;

 sub f i -> fi;

}

 

and the latter declaration will have the proper result. Why? When the sequence "f i" is encountered it will be replaced by the fi character and will no longer match the f f i sequence. In the latter example "f f i" is matched before "f i" and the result is as expected.