psychopy.org | Reference | Downloads | Github

Text kerning causing Chinese character overlap

Win 10, Psychopy 1.85.2

When trying to display Chinese characters, the kerning causes the characters to overlap. Can I add a code box to change the space between the characters or the font to properly display the characters? Any recommendations for displaying Chinese text would be helpful!

Edit:
I think this might have more to do with setting the text width since it is dependent on an aspect ratio of the height. I’ve tried the previous solution of setting font= ‘Songti SC’ but it does not fix the issue.

Thanks,
Stacy

Stacy and I figured out that this was simply a matter of changing to a compatible font. There were two stumbling blocks, the first was simply finding the correct name of the font (as far as psychopy / pyglet was concerned), which was not super straightforward and took a bit of guesswork. One thing we did to check if pyglet is finding the font was adding a code component with something like this, which only works if your psychopy is using pyglet of course:

import pyglet
print(pyglet.font.have_font("Font Name"))

The second issue seemed to be that we couldn’t get a font with a .ttc extension to work. We downloaded and installed the Google font “Noto Sans CJK TC” , specified the variation of the font with “Noto Sans CJK TC Regular” in the TextStim options, and it worked. (Maybe we could’ve gotten the .ttc file to work by using a different name, but I’m not sure)

I don’t have much time at the moment to look into it, but from a usability standpoint it would be nice to have some type of warning indicating that a font specified by the user could not be loaded.

It’s also not really clear to me how to find out the acceptable name for a given font on a Windows machine. We dug around the pyglet code a bit looking for a list of available font names, but didn’t find it super easily and it ended up not being worth figuring it out since we got her experiment to work.

If anyone could shed light on these questions it would be good to have this posted, because this issue has come up before, at least for Chinese text rendering: https://groups.google.com/forum/m/#!topic/psychopy-users/EtKszAYLhBo

I think this is just the list of fonts available to the OS, which can be found like this:

1 Like