Page 1 of 1

Context Chain Substitution

Posted: Fri May 22, 2020 5:09 pm
by Lesley Prince
Hello
I am having trouble with Chained Context Substitution. What I want to achieve is to substitute a normal 's' for the 'long s' as used in C17 and C18 writing. So far I have managed to use ligature substitution, but the long s requires some sensitivity to context. I have set up a substitution table as an alternate and I have managed to get into the context dialogue but what I can't do, or don't know how to do, is specify the context, i.e. that when 's' is flanked by other letters, it becomes the long s. How do I specify that all (lower case) letters are included in the flanking criteria? I have read the tutorials and other posts, but I am none the wiser.

Yours in anticipation,
Puzzled of Nottingham

Les Prince :roll:

Re: Context Chain Substitution

Posted: Fri May 22, 2020 7:11 pm
by Erwin Denissen
I hope this OpenType feature code helps:

Code: Select all

script latn {
  feature ContextualAlternates;
}

class @letters [a-z A-Z];

feature ContextualAlternates calt {
  lookup ChainingContext1;
}

lookup ChainingContext1 {
  context (@letters) s;
  sub 0 SingleSubstitution1;
  context s (@letters);
  sub 0 SingleSubstitution1;
}

lookup SingleSubstitution1 {
  sub s -> longs;
}

Re: Context Chain Substitution

Posted: Wed Jun 03, 2020 12:06 pm
by Lesley Prince
Thank you, Erwin
That is very helpful. I will try it out when I get back to 'The Beast' upstairs.
Best wishes
Les

Re: Context Chain Substitution

Posted: Wed Jun 03, 2020 8:35 pm
by Erwin Denissen
Perfect. I look forward to your results.

Since the latest updates of FontCreator also support fea feature code, you can also use this.

Code: Select all

languagesystem latn dflt;

@letters = [a-z A-Z];

lookup SingleSubstitution1 {
    sub s by longs;
} SingleSubstitution1;

feature calt { # Contextual Alternates
    sub @letters s' lookup SingleSubstitution1;
    sub s' lookup SingleSubstitution1 @letters;
} calt;
Both will result in the exact same OpenType layout features, but FEA is a more common syntax, so it might help other people who are looking for a similar solution.