Article written by

A passionate pythonist geek looking for problems, to solve :P

13 responses to “Python Arabic Text Reshaper”

  1. Khaled

    بارك الله فيك اخي عبدالله
    أرجو ان يساعدني هذا في العديد من الامور التي لا تدعم اللغة العربية
    أتمنى أن نتواصل على الايميل

  2. Louis

    Hello Abd,
    Thank you for this *extremely* valuable port. Quick question, regarding “single letters”.
    Your algorithm reshapes an isolated letter, such as ض (\u0636) into a shaped one : ﺿ (\uFEBF).
    I don’t think this is correct (?) I consider adding a line of code at the very first line of the function “get_reshaped_word” to exclude 1-letter words. Would it make sense?

    def get_reshaped_word(unshaped_word):
    if len(unshaped_word) == 1: return unshaped_word ### <—– New
    unshaped_word = replace_lam_alef(unshaped_word)
    decomposed_word = DecomposedWord(unshaped_word)

  3. waleed

    بارك الله فيك
    شغالة معايا تمام
    تسلم

  4. Cüneyt Sina Koca

    Thanks for this project, just wanted to inform that my problems regarding the error :

    UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-4: ordinal not in range(128)

    is solved by putting the following lines in arabic_reshaper.py :

    import sys
    reload(sys)
    sys.setdefaultencoding(‘utf-8′)

  5. Mohamed LICHOURI

    In first, thanks for sharing this code, but i have a problem with the example that you provided.

    pass_arabic_text_to_render(bidi_text)
    NameError: name ‘pass_arabic_text_to_render’ is not defined

  6. Razan

    Assalam Alykum

    Thank you brother for your great effort and sharing it , Now i can finally use beautiful arabic fonts in Linux for OpenERP arabic Reports.
    which the arabic_reshaper.py was suggested as a part of solution for OpenERP arabic reports in https://github.com/barsi/openerp-rtl

    i have noticed that there is vertical alignment Problem when generating the reports . the data is not vertically well aligned. am just asking is this issue related to the reshaper or to the Reportlab represntation for the arabic font.

    note that before i use the solution in the link [ https://github.com/barsi/openerp-rtl ] some fonts were well aligned but they have the square thing issue , now they are ok but not well aligned vertically !!!

  7. Razan

    Thanks in advance :)

Leave a Reply