Contextual alternates puzzling me

Hello
I have been learning from tutorials and forums all about glyphs. I have recently started using contextual alternates for a cursive font. I need some help with the caalt code.
So for most of my lower letters i have two states ie normal and .alt, with this everything worked like a charm where letter changes if any other letter follows it.

Next I started experimenting with my s, i have three states.

The problem is in the following image in step 4 where s.alt1 is getting replaced by s.alt when followed by a t. How can i fix this so that it stays as s.alt.

Thanks for helping in advance as I am just loving glyphs so much.

Regards,
Mazhar

Can you post the full feature code?

Sure.

Liga

lookupflag IgnoreMarks;
sub f f i by f_f_i;
sub f f l by f_f_l;
sub f f by f_f;
sub f i by f_i;
sub f l by f_l;
sub f j by f_j;
sub f t by f_t;
sub s s by s_s;
sub t t by t_t;

calt:

sub a' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by a.alt;
sub b' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by b.alt;
sub c' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by c.alt;
sub d' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by d.alt;
sub e' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by e.alt;
sub f' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by f.alt;
sub g' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by g.alt;
sub h' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by h.alt;
sub i' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by i.alt;
sub j' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by j.alt;
sub k' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by k.alt;
sub l' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by l.alt;
sub m' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by m.alt;
sub n' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by n.alt;
sub o' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by o.alt;
sub p' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by p.alt;
sub q' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by q.alt;
sub r' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by r.alt;
sub s' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by s.alt;
sub t' [a b c d e f g h i j k l m n o p q r s s.alt t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by t.alt;
sub u' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by u.alt;
sub v' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by v.alt;
sub w' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by w.alt;
sub x' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by x.alt;
sub y' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by y.alt;
sub z' [a b c d e f g h i j k l m n o p q r s t u v w x y z f_f f_f_i f_f_l f_i f_j f_l f_t s_s t_t] by z.alt;
sub [t.alt] s' by s.alt1;
sub s.alt1 t' by t.alt;

So i have code in liga, calt and frac only

This is indeed an easy area to get confused about. Your current substitution code is too unwieldy to manage, and the brute-force iteration approach also can’t achieve the glyph variant management you’re actually after.
Implementing it requires some programming-oriented thinking — my personal recommendation is to seek help from AI. I just tried writing a prompt that should be able to help you:
https://www.perplexity.ai/search/5f84151f-29fb-45c6-8094-402dd179da23

did you read this tutorial: Features, part 3: advanced contextual alternates | Glyphs

Thanks George, I actually did but i was too late and was confused by the contextual vs stylistic alternates. Anyhow I was try this full font based on new learnings from this tutorial.

Also I had a good chat with chatgpt and felt like I was talking to you. It solved the issue with changes to my code and had a lot to do with special behaviour added to code. I am trying to understand how the code fixed it all as I am such a noob. I can share the code if you want.

1 Like