Reversed chaining context help needed

Hello ! :slight_smile:

I finally managed to understand how to use Chaining Context and it’s working. I use it so that when I type a letter belonging to a class(v, w, b, for example) I have specific letters which are used instead of the “normal” ones.

Now, I need to replace a specific letter in a word (when it’s being written), when I type the next lower case letter.

I told myself I should use Reversed chaining context. I tried but it doesn’t work.

Here is what I wrote :

script latn {
  feature ContextualAlternates;
}

class @lowercase [a-z];
class @lettertochange [q s];     ----> these are the letters I need to chane at the end of a word (birds for instance).
class @lettertouse [q.eow s.eow];     ----> these are the letters which should replace the letters q and s

feature ContextualAlternates calt {
  lookup ReverseChainingContextLetterEow;
}

lookup ReverseChainingContextLetterEow {
  reverse context (@lettertochange)(@lowercase);
  sub ReverseSubstitutionLetterEow;
}

lookup ReverseSubstitutionLetterEow {
  sub @lettertochange -> @lettertouse;   ----> Is supposed to replace the letter to change (s or q) by the letter to use (q.eow s.eow)
}

Can you tell me why it doesn’t work ?

Can you give me an example of a working code for Reversed chaining context ?

Thank you ! :slight_smile:

Here is an image showing what I want to do :

Please, tell me if I chose the wrong solution.

Thank you. :slight_smile:

Reverse Chaining contextual single substitution is specifically meant for Arabic script writing styles. Unfortunately terminal forms (fina) can’t be used either as that is also meant for Arabic scripts.

But fortunately there is an elegant way to achieve what you want. This code, based on OpenType feature code from this post should do the trick:

script latn {
  feature ContextualAlternates;
}

class @lowercase [a-z];
class @lowercasefina [a.fina-z.fina];
class @lowercase_all [A-Z a-z a.fina-z.fina];

feature ContextualAlternates calt {
  lookup ChainingContextFina;
}

lookup ChainingContextFina {
  context (@lowercase_all) @lowercase;
  sub 0 SingleSubstitutionFina;
}

lookup SingleSubstitutionFina {
  sub @lowercase -> @lowercasefina;
}

Thank you. I will try to use this code and understand how it works to use it axactly as I need. :slight_smile:

It works fine. Thanks a lot. :slight_smile: