Open Type Feature - Contextual Alternates

Hi,

I’m currently facing an issue with the medial letters — specifically:
beh-ar.medi, teh-ar.medi, theh-ar.medi, noon-ar.medi, yeh-ar.medi, and yehHamzaabove-ar.medi — when they appear consecutively in writing.

I have implemented contextual substitution code as follows:

sub [@beh_source_medi @noon_source_fina]’ by [@beh_source_tooth_fina @noon_source_tooth_fina];
sub [@beh_source_medi @reh_source_fina] by [@beh_source_tooth_fina @reh_source_tooth];
sub @beh_source_medi@beh_source_medi by @beh_source_medi;

This was intended to produce the output shown in the attached image (02).

However, when I type sequences of these medial letters, they do not connect correctly, as shown in the attached image (01).

I need the output to render as shown in the corrected example (02), where the letters connect properly.

*Note: I made classes as follows:
beh_source_medi:
beh-ar.medi teh-ar.medi theh-ar.medi noon-ar.medi yeh-ar.medi yehHamzaabove-ar.medi

beh_source_tooth_fina:
beh-ar.medi.tooth teh-ar.medi.tooth theh-ar.medi.tooth noon-ar.medi.tooth yeh-ar.medi.tooth yehHamzaabove-ar.medi.tooth

reh_source_fina:
reh-ar.fina zain-ar.fina

reh_source_tooth:
reh-ar.fina.tooth zain-ar.fina.tooth

noon_source_fina:
noon-ar.fina

noon_source_tooth_fina:
noon-ar.fina.tooth

Could you please help me resolve this?



Why do you need contextual features at all. having an init, medi and fina feature should be enough. Where do you test this?

I want to tell Glyphs to replace the medial letters (beh-ar.medi teh-ar.medi theh-ar.medi noon-ar.medi yeh-ar.medi yehHamzaabove-ar.medi) with their alternatives (beh-ar.medi.tooth teh-ar.medi.tooth theh-ar.medi.tooth noon-ar.medi.tooth yeh-ar.medi.tooth yehHamzaabove-ar.medi.tooth) when these medial letters precede the final letters (reh-ar.fina zain-ar.fina noon-ar.fina )

And to replace the final letters (reh-ar.fina zain-ar.fina noon-ar.fina) with their alternatives (reh-ar.fina.tooth zain-ar.fina.tooth noon-ar.fina.tooth) when these final letters follow the alternative medial letters (beh-ar.medi.tooth teh-ar.medi.tooth theh-ar.medi.tooth noon-ar.medi.tooth yeh-ar.medi.tooth yehHamzaabove-ar.medi.tooth)

And that the medial letters are not affected when they follow each other, as in attachment No (1)

Now I understand.
You misunderstand how context features are written.

sub [@beh_source_medi @noon_source_fina]' by [@beh_source_tooth_fina @noon_source_tooth_final];

Putting those two classes in brackets mans that those classes are merged into one. So this means that all medi and final glyphs will be replace unconditionally.
What you what might be:

sub @beh_source_medi' @noon_source_fina by @beh_source_tooth_fina;

The tic after the medi class marks those glyphs to be replaces IF whatever comes before and after (in that case only after) it. The medi class is the “input” and the fina class is the context.

I will try
Thanks

I found the correct code as below:

sub @medi_default' @rzn_default by @high-tooth_alt;

sub @high-tooth_alt @rzn_default' by @rzn_alt;

Thank you @GeorgSeifert