Contextual substitutions with three classes

Hello everyone,
I’m working on a font with lots of possible ligatures (130 so far) that are formed by combining 2 to 3 letters. David Jonathan Ross took a look at it, and advised me that, rather than creating endless ligatures, I could do better by creating different glyph forms and combining them through contextual substitutions. So I followed the online Glyphs tutorial for substitutions (parts 2 and 3), I created four classes (DEFAULT, INITIAL, MEDIAL and FINAL) and then put my variant glyphs in these classes. I started a test with the letter A, so I put the regular A in the DEFAULT class, A1.calt in the INITIAL class, A2.calt in the middle class, and A3.calt in the FINAL class obviously. So I started writing my code in the “calt” section:

sub @DEFAULT' @DEFAULT by @INITIAL;
sub @INITIAL' @DEFAULT by @FINAL;

(NOTE : I’m putting a space between the @ and the classname here because otherwise the Glyphs forum thinks I’m calling out other users and won’t let me post this question, in my code there’s no spaces.)
edit: I added three grave (backtick) before and after the code.

I compiled the code and I tested it. So far so good. When I write “AA”, the first one gets replaced by the initial form and the second one gets replaced by the final form.
The trouble starts when I try to make it in a way that when I write “AAA”, the middle A gets replaced by the MEDIAL form,

sub @DEFAULT' @DEFAULT by @INITIAL;
sub @INITIAL' @DEFAULT by @FINAL;
sub @INITIAL @FINAL' @DEFAULT by @MEDIAL;

This doesn’t work, and I’ve tried many combinations and orders of these expressions and the result is always INITIAL INITIAL FINAL, not INITIAL MIDDLE FINAL. So, do you have any ideas on how to implement this code?

Ideally, if I wrote “AAAAAA”, the first one would be the INITIAL form, all the As in the middle would be MEDIAL and the last one would be the FINAL form. I looked up the tutorials and none of them treated this kind of situations.
(Why don’t I go with positional alternates? because I want the A to change its shape when next to particular glyphs, and not others, for instance A changes when next to another A but doesn’t change when it’s next to an O).

Thanks in advance!

The Final substitution replaces the wrong glyph. Also, you need to replace at word boundaries. There is a tutorial called “positional alternates“ which describes this in detail.

Thanks, I’ll look into that :+1:

Here the link:
https://glyphsapp.com/tutorials/features-part-4-positional-alternates

1 Like