Hi! I’m building a script for RSVP study in Arabic, but the script crashes whenever it encounters a word with diacritics (if there are no diacritics, the script works fine). I’ve tried resolving this issue by using several fonts (e.g., Arial, Sahel,…) , the problem persists. Here is the line of the script for the stimulus:
stim = visual.TextStim(win, text=words[wordIndex], languageStyle=‘Arabic’)
And the error message I get is:
TypeError: ord() expected a character, but string of length 2 found
I suspect the issue might be with the text input. The variable words[wordIndex] contains Arabic text, but I’m not sure how to verify or fix it. How can I resolve this? Thanks for any help!
The full traceback is:
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\text.py”, line 230, in init
self.setText(text, log=False)
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\text.py”, line 395, in setText
setAttribute(self, ‘text’, text, log)
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\tools\attributetools.py”, line 140, in setAttribute
setattr(self, attrib, value)
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\tools\attributetools.py”, line 29, in set
newValue = self.func(obj, value)
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\text.py”, line 386, in text
self._setTextShaders(text)
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\visual\text.py”, line 404, in setTextShaders
self.pygletTextObj = pyglet.text.Label(
File “C:\Users\vpixx\AppData\Roaming\Python\Python310\site-packages\pyglet\text_init.py”, line 452, in init
super(Label, self).init(document, x, y, width, height,
File “C:\Users\vpixx\AppData\Roaming\Python\Python310\site-packages\pyglet\text_init.py”, line 273, in init
super(DocumentLabel, self).init(document,
File “C:\Users\vpixx\AppData\Roaming\Python\Python310\site-packages\pyglet\text\layout.py”, line 820, in init
self.document = document
File “C:\Users\vpixx\AppData\Roaming\Python\Python310\site-packages\pyglet\text\layout.py”, line 929, in _set_document
self._init_document()
File “C:\Users\vpixx\AppData\Roaming\Python\Python310\site-packages\pyglet\text\layout.py”, line 1043, in _init_document
self._update()
File “C:\Users\vpixx\AppData\Roaming\Python\Python310\site-packages\pyglet\text\layout.py”, line 966, in _update
lines = self._get_lines()
File “C:\Users\vpixx\AppData\Roaming\Python\Python310\site-packages\pyglet\text\layout.py”, line 942, in _get_lines
glyphs = self._get_glyphs()
File “C:\Users\vpixx\AppData\Roaming\Python\Python310\site-packages\pyglet\text\layout.py”, line 1085, in _get_glyphs
glyphs.extend(font.get_glyphs(text[start:end]))
File “C:\Users\vpixx\AppData\Roaming\Python\Python310\site-packages\pyglet\font\base.py”, line 394, in get_glyphs
self.glyphs[c] = glyph_renderer.render(c)
File “C:\Users\vpixx\AppData\Roaming\Python\Python310\site-packages\pyglet\font\win32.py”, line 432, in render
ord(text), ord(text), byref(abc)):
TypeError: ord() expected a character, but string of length 2 found