Word wrapping of multi-line Arabic text

Hello,

Thanks for your message. We do want to get this right, and might need to ask for your help to troubleshoot this further.

The issue you’ve identified with the older TextStim class is known, and not something we can improve upon, because the order of drawing of the text is out of our control with that particular stimulus (it’s handled by a third-party library called pyglet):

The current situation is that it seems to work correctly for single-line text, in that text is displayed right-to-left, and the individual glyphs are linked to each properly. But the alignment may still be wonky (i.e. text doesn’t seem to align properly to the right).

However, we now have a newer Textbox stimulus (because it allows for editable text, you’ll find it under the “Responses” section of the component panel). This has the advantage that the drawing is under the control of PsychoPy developers, so we should be able to better change the way it behaves.

I’ve just tested it however, and it is more substantially broken.

@jon: here is an example contrasting the two text stimuli, using this example Farsi text string:

در نسخه آخر سایکوپای، مشکل تبدیل متون انگلیسی به فارسی حل شد و از این پس شما قادر خواهید بود که در آزمایشات خود از متون فارسی استفاده کنید

TextStim behaves correctly:

  • text flows right to left (using the bidi algorithm to allow mixing of bi-directional text),
  • characters are linked cursively to their neighbours (using the arabic-reshaper module),

and incorrectly:

  • lines flow from bottom-to-top, rather than top-to-bottom, and

unsure:

  • the text alignment is centre-aligned

TextBox2 doesn’t respond to language style settings. Even when set to 'Arabic':

  • the text flows left-to-right,
  • characters are not reshaped (i.e. linked to their neighbours cursively, which wouldn’t be possible, as they are flowing in the wrong direction), being displayed in their isolated form.

One could say that it is behaving correctly in that the lines run from top-to-bottom, but I think that is because it is actually being displayed as LTR language style, because changing the language style ('LTR', 'RTL', or 'Arabic') has no discernible effect.

@Jon - from the API it looks like language styles aren’t actually implemented for TextBox2, so I guess that setting is just being accidentally exposed via the Builder interface, and hence is ignored for that component.

I’ll try to take a look at it over the weekend. But given what you know of how TextBox2 works under the hood, what are the chances of us correctly implementing RTL and Arabic language styles for it, while correcting the inherent bottom-to-top flow issue in TextStim?

1 Like