I have the following code:
ignore sub f' @f_long_blocker;
sub f' by f.long;
I hope you get the idea: replace the f with f.long except before glyphs like l etc.
It compiles and seems to work but: Is it a hack? Will it bite me in a situation I haven’t tested yet? I have never seen an example where '
was used without a trigger.
Btw. this would be an alternative solution. It’s less elegant, though.
lookup lookup_0 {
sub f by f.long;
} lookup_0;
lookup lookup_1 {
sub f.long' @f_long_blocker by f;
} lookup_1;
Your first code snippet is legal. The AFDKO spec states for ignore rules specifically:
The backtrack and lookahead sequences may be omitted, but there must be at least one marked glyph or glyph class.
And this applies more generally to all contextual substitutions:
The most important is input glyph sequence. This is the sequence of glyphs and glyph classes to which substitution operations are applied. Optionally, a prefix (also known as backtrack) glyph sequence may be specified, as well as a suffix (also known as lookahead) glyph sequence.
From: OpenType Feature File Specification | afdko
Thanks for the confirmation, and the quotes. It feels a bit funny to write something like that but it’s probably a mater of habit.
I don’t quite understand why the spec doesn’t allow to omit the '
(and silently make it a contextual substitution). IMHO that would make the code (the intention) more readable but never mind.
The AFDKO syntax already harms understandability by automatically switching stuff around without you noticing, so I like to be explicit. E.g., the ignore sub
rule is just syntax sugar for a normal sub
, but it looks like it is a separate construct with separate rules.