PsychoPy presenting text in Persian/Arabic

[The rest of this post is now outmoded - PsychoPy (at least when running locally) should now display Arabic and Farsi text correctly. In your text component, click the “Formatting” tab and select “Arabic” as the language style. Not all fonts will correctly display Arabic text, however. Start with Arial, as a good option on Mac and Windows: the default option of Open Sans doesn’t seem to work well.]

Some years ago, it was noted that PsychoPy does not correctly display Persian or Arabic text stimuli. Strings can be pasted correctly into dialog boxes but when displayed on-screen as stimuli, the characters are displayed left-to-right rather than right-to-left and the individual glyphs are isolated, not correctly flowing into each other as influenced by their neighbouring characters.

These issues were discussed here by PsychoPy users and developers, with some text and pictorial examples provided for reference:
https://groups.google.com/forum/#!topic/psychopy-users/HJgyKNaSlKQ

and some work-arounds noted. In particular, Abdullah Diab provides an online ‘reshaper’ for Arabic text here:
http://pydj.mpcabd.xyz/arabic-reshaper/

He describes the issues involved here:
http://mpcabd.xyz/python-arabic-text-reshaper/

That online service can be used to ‘re-shape’ text so that although it no longer looks correct in a dialog box in PsychoPy or in a conditions file, it will be rendered correctly on screen in text stimuli. Abdullah also maintains this as a Python package here:
https://github.com/mpcabd/python-arabic-reshaper

so this function could be integrated into PsychoPy so users don’t have to make workarounds, such as re-shaping text themselves or displaying text via images.

Alternatively, PsychoPy is also not too far away from making the transition to Python 3. The improved Unicode handling there might (possibly) help with this situation.

Are there Arabic- or Farsi-speaking PsychoPy users who would be willing to do some testing of ways to address these issues? Apart from @hsogo12600, who has done great work over the years to localise PsychoPy into Japanese, most of the PsychoPy developers work with Latin scripts and would need help to understand the issues involved.

3 Likes

See here for an update on adding this functionality directly within PsychoPy:

Hello Michael,
I am using PsychoPy for an Arabic self-paced reading task. The letters still not connected when I run the experiment. It is from right to left but still there is a gap between the characters.

Kind regards,
Ala’a

Can you post a minimal working example here (i.e. a .psyexp file along with any Excel or .csv file needed to contain the text) for us to check?

(post deleted by author)

(post deleted by author)

Thanks, but I really need to be able to see the Builder .psyexp file that was used to generate that .py script (and any other files required to be able to run the experiment).

The thing you are taking a screenshot of is a file that is probably called Reading Demo.psyexp which I guess is sitting on your desktop, and there should also be a file there called Book2.xlsx.

You start by looking in the same place (your desktop I think) where you were able to find Reading Demo_lastrun.py.

It might be that you don’t have your operating system set to show file extensions, in which case those files might just appear as Reading Demo and Book2.

Thanks for the Excel file. But I really need to see the Builder .psyexp file, NOT the .py “lastrun” Python script.

If I have the Builder file, I can generate the .py file from it if needed.

If I don’t have access to the actual Builder file you’re using yourself, I can’t give you useful instructions.

It should be the file (in the same exact location where you got the Excel file and the .py script), which is called Reading Demo.psyexp (or Reading Demo if you have extensions turned off). It does not have lastrun in its name.

Actually, just checking this last .py file you sent, the Builder file it is associated with would be called EX.psyexp.

Reading Demo.psyexp (8.0 KB)

Please bear with me this is my first trial on PsychPy. Thank you

Please bear with me, as I can’t read Arabic. But this just seems to be a font limitation rather than a problem with PsychoPy itself. In the file you sent, the text component is set to use the font Open Sans. I changed this to Arial and the situation seems to be resolved. The screenshot below shows Open Sans above and Arial below. Is the lower version now correct?

1 Like

Thank you so much.
It’s because of my lack of knowledge of the software not a a problem with PsychoPy.

Thank you for your patience.

No problem, we were all learners once. Good luck with your experiment.

Very much appreciated.

Adding Arabic to the software is extremely helpful.

1 Like