Arabic-style script with initial, medial etc. forms

You may have to work out the code on your own as most of us don’t use Arabic scripts.

This thread on creating a fraction feature demonstrates contextual substitutions.