Three letters and two ligatures

Hello.

I Googled and searched the forum for two hours, but I still couldn’t find it. GPT chat tries to help, but constantly writes different things :slight_smile:

Situation. There are ligatures D_O.liga and O_O.liga. Everything is fine, everything is being replaced.
But in a situation with the sequence of letters DOO, only the ligature O_O.liga should work. I think this is a simple situation, but… how to do it?

The Learn section has great lessons like Features, part 3: advanced contextual alternates | Glyphs. But this situation does not exist.

GPT chat writes something like:

feature calt {
sub D O by D_O.liga;
sub O O’ @DOOContext by O_O.liga;
} calt;

It’s as if there is a team that, in a DOO situation, changes only the second pair of letters to the ligature O_O.liga, without applying D_O.liga to the first pair.

Thank you.

From the OpenType Cookbook

What if we have a short context that you want to match, but a longer context that contains the short context? For example, say we want to change the r in words but not in words!. To do that we can specify an exception to the contextual rule. For example:

ignore sub w o r' d s exclam;
sub w o r' d s by r.alt;

The ignore keyword followed by a backtrack (optional), target and lookahead (optional) creates the exception.

1 Like

I admit, I still haven’t figured out how to do this.
Last thing I tried:

ignore sub D' O O;
sub D' O' O by D_O.liga;

Apparently I don’t understand how this works in my case.
But I realized that it works through "ignore’. And on the forum I found a piece of code that I was able to change for myself:

lookup OOliga {
    sub O O by O_O.liga;
} OOliga;
lookup DOliga {
    ignore sub D' O_O.liga;
    sub D' O' by D_O.liga;
} DOliga;

(At the same time, I had to remove the conflicting teams from the “liga”)

It works. But it seems to me that you were talking about an even simpler solution.

Thank you for your help!

No Ignore needed. Make one lookup that substitutes the OO and one that does the DO.

1 Like

Yes!
The main thing is that the OO is first, and then the DO.
Thank you!

lookup OOliga {
    sub O O by O_O.liga;
} OOliga;

lookup DOliga {
    sub D O by D_O.liga;
} DOliga;