I see in the tk source code in the Tkbind.c, TkEvent.c and TkEntry.c that there are a set of pointers, eventPtr, dispPtr, bindPtr, and a few more pointing to different C-structures.
There is eventPtr which stores information relating to which key is pressed. Then the bindPtr takes an appropriate glyph from the hashtable, corresponding to the keySym from eventPtr and stores the result to the structure pointed to by patPtr (pattern pointer).
An example would help, I guess.
So, I press key "A". This is what goes in eventPtr. If I have CAPS LOCK off, then the actual text would be "a" and therefore the corresponding glyph "a" is picked from the hashtable by bindPtr. This "a" is passed onto patPtr.
In case, I want to write arabic, again pressing "A", gives the same keySym in eventPtr. From the hashtable, bindPtr will choose the appropriate glyph of " ش". In arabic the glyphs can be different due to the joining of the letters, even for the same letter. The appropriate glyph is passed onto patPtr.
This is then passed on to the dispPtr. I know (or at least I think) that these pointers to structures are used to form a linked list which is then handed over to the system/platform resources to render the text on the widget.
Am I on the right track so far or ... ? I ultimately, intend to use fribidi (binary or if not the binary then, the dynamic link library with the corresponding header files) to enable tk to handle arabic. If fribidi is not the appropriate choice then I would go for pango/cairo or something further.
thanks ! p.s. I know this question is sort of specific that only Tcl/Tk maintainers/developers could answer. I hope it is the right place to ask this !