Arabic Substitution code with numbers in the rule


So, i want the Rial Currency unicode glyph to appear whenever someone types a number followed by the Rial arabic letters, i tried all i can try and it seems that because numbers are left-to-right it does not work!

Did anyone figure before how to do this?

i tried:

sub @arabic-numbers reh-ar' yeh-ar.init' alef-ar.fina' lam-ar' by rial;
sub @arabic-numbers space reh-ar' yeh-ar.init' alef-ar.fina' lam-ar' by rial;

It is not working


It worked for me at least inside Glyphs,

@arabic-numbers class
zero-ar one-ar two-ar three-ar four-ar five-ar six-ar seven-ar eight-ar nine-ar

Inside the calt block
sub @arabic-numbers reh-ar' yeh-ar.init' alef-ar.fina' lam-ar' by rial;

Do you have lookupflag IgnoreMarks RightToLeft on top of the block? Not sure if that’s require. Make sure the ‘calt’ feature is enabled inside the edit view and that the text direction is RTL. Also try placing the code in its own calt block.


Glyphs doesn’t contain a proper Arabic engine and is not to be trusted in those cases.

You are right, it is not possible because of the different direction of the numbers and the letters. The OpenType processing is split between the two and that breaks the context.


Should not be done either. That would be substitution of characters for another. It is the user’s and the layout engine’s job to type and change characters. The font should only mess around on the glyph level.


@aiaf Yes this works in Glyphs but not in or anywhere else, so no go.

@GeorgSeifert This is sad :frowning:

@mekkablue Think of it as a style, like the way we style “Allah” الله automatically for the user without the user’s need to type the accents him/her self.


الحمد لله تعالى
Allah provided a way to do it:
Before the sub code, using an ignore sub with a class that has all arabic letters sans the numbers

ignore sub @ar-letters-only space reh-ar.001' [yeh-ar.init yeh-ar.init.0001]' alef-ar.fina' lam-ar';
ignore sub @ar-letters-only reh-ar.001' [yeh-ar.init yeh-ar.init.0001]' alef-ar.fina' lam-ar';

I thank HIM greatly :heart: