Contextual alternates with exceptions

Hello.

I’m working on a font that has a lot of contextual alternates. The substitutions depend on which letters sit on left or right side of a letter because some of the letters should connect to each other. When a letter connects to another letter the serif is adjusted. Therefor i name the glyphs in such a way:
N (for the default N)
N.left (for when the N has an adjusted serif on the left side)
N.right (for when the N has an adjusted serif on the right side)
N.both (for when the N has an adjusted serif on both sides)

So if i for example want to write UN:

U needs to be subbed by U.right
N needs to be subbed by N.left

The code i wrote as a calt feature is:
sub U’ N by U.right;
sub U.right N’ by N.left;

Likewise if i want to write NE:
N needs to be replaced by N.right
E needs to be replaced by E.left

My calt feature code for this is:
sub N’ E by N.right;
sub N.right E’ by E.left;

So far so good, these are working, but the problem accurs if i then want to write UNE.

I now need the N to have the adjusted serif on both sides so i want to sub it with N.both.

I try the code:
sub N.left’ E by N.both;

But somehow this doens’t work. The N.left is not reacting.
So this is the full code so far:

sub U’ N by U.right;
sub U.right N’ by N.left;
sub N’ E by N.right;
sub N.right E’ by E.left;
sub N.left’ E by N.both;

In general i’m also unsure if this approach is the right way to go, because there will be a lot of alternates and i will end up with a lot of code. If someone can point me to the right resource for me to look into in i would be grateful.

It is the same situation as with script fonts. You should be able to do that if you follow this tutorial: Features, part 4: positional alternates | Glyphs

1 Like

@Szakoba thanks a lot for the reply!
It’s similar, yes - except in my case i don’t need the connecting stroke for all letters that are in the middle of a word. If for example a letter comes right before or after a round letter like O, then the rounded connecting serif should not be added. So i need quite a lot of control of every individual meeting between various characters.

That should be possible to do witch additional ignore sub statements. I guess you should define classes for letters that don’t have a serif on the top right, another for top left, bottom right and bottom left. I would experiment in that direction.

1 Like

Thanks, it sounds like a good direction to explore.