Problems rendering unicode text with ligatures (in Devanagari)

OS: MacOS 11.6.7
PsychoPy version: v2022.2.2
Standard Standalone? (y/n) : Y

What are you trying to achieve?:
I am trying to display three-character unicode strings as their appropriate ligature glyph in Devanagari using an appropriate font. As an example, I am trying to display the text ‘क ् ष’ (characters separated by spaces for visualization here) as the glyph क्ष in a unicode font like Arial Unicode MS or a more specialized font like Kohinoor Devanagari, using either TextStim or TextBox. This glyph is a ligature - i.e. it is a glyph that represent the sequence of 3 unicode characters (U+2325, U+2381, U+2359).

What’s the problem:
Instead of seeing the क्ष, I see क् ष (without the space - see attached screenshot). I can correctly print the appropriate glyph to the output with the print statement. I also get the correct glyph saved in the data csv. However, the text display is क् ष. Here the first two unicode characters were combined, but the third one was not combined (as it should be). In other software using the exact same font, I get the correct behavior.

Screen Shot 2022-07-28 at 5.55.19 PM

What did you try to make it work?:

  • Tried various fonts - for many others, I get even worse results (empty boxes, clipped off glyphs).
  • Tried normalizing the text using unicodedata.normalize (using the NFC or NFKC forms.
  • Tried both TextSim and TextBox components
  • Tried redoing completely in code rather than via builder.

Can’t tell if this is a problem with PsychoPy, pyglet, the fonts, or with the fact that I’m using a Mac or something else. Any insight is appreciated!

PS - I can obviously use a workaround with images instead of text, but being able to display text would be a MUCH more efficient solution.

1 Like

I would also like to know this answer!!