I've tried justification before, it doesn't fix the problem: the wrapping remains the same, and the lines are the same. The lines are just "pushed" to the right as they are.
The Problem with right-to-left text is that the last words of the text are at the beginning of the string. These words go to the top line upon wrapping (since it's the beginning of the string). Same for the first words of the text - they are at the end of the string and go to the lowest line upon wrapping.
First, I thought of rearranging the text when the user hits "enter" (before the wrapping), according to the chat frame size. However, I found out that the width of the characters is taken into account for wrapping. For example you can put more "iiiiiiiii..." in a wrapped line than "aaaaa....." since "a" is wider than "i". That means there is no fixed number of chars in a wrapped line. So I really don't know how to calculate it and know in advance how to rearrange the text just before the text is sent and the wrapping occur.
Will be happy for more help and ideas