Contextual substitutions and ligatures

How do I write code that says “substitute these ligatures, but not after this specific class(es) of letters”? eg, ‘a f_i’ but ‘b f i’

Also, how to I write code that says “if ‘a’ is followed by ‘b’, substitute ‘c’ for ‘b’, but not if ‘b’ is followed by a space (or period etc).”

To your first question, two ways are possible and it depends on which are more rare.

Case 1. Ligature cases are more specific and rare (assuming a and n triggers the ligature)

lookup contextual_ligature {
	sub [a n] f' i' by f_i;
} contextual_ligature;

Case 2. Ligature cancellations are more specific

lookup contextual_ligature {
	ignore sub [b p] f' i';
	sub f' i' by f_i;
} contextual_ligature;

The square brackets is how you can make a class/group on the spot.

And for the second question:

lookup b_substitution {
	ignore sub b' space; # if b is followed by the space, the rest of this lookup doesn't happen
	sub a b' by c; # if b is preceded by a, it becomes c
} b_substitution;

I may be getting the details of your question wrong, but there should be enough parts to serve your needs.

Thanks, Toshi, I’ll give it a try