psychopy.org | Reference | Downloads | Github

Unicode symbols cut off

hello – question about using unicode symbols in an experiment. I have read other posts and am able to present them on screen, but many of them get cut off like there is some character bounding box which they are too big for. this is regardless of letter height / location on screen. a basic program example below, which shows that longer text can be shown fine but these single characters are cut. screenshot of what one looks like on my screen shown below. any advice on how to fix / expand bounding box would be great! thank you!

from psychopy import visual, monitors
from psychopy import core, event
win = visual.Window(size=[1400, 900],pos=[0,0],color='black', fullscr=1, mouseVisible=False)
symbol_choices = ['hello world','\u2744','\u2601','\u2605','\u2600','A','B','hello']
for s in symbol_choices:
	visual.TextStim(win,text=s).draw()
	win.flip(); core.wait(2)
win.close()

Hi,

Just a performance suggestion first: creating stimuli takes longer than changing the attributes of an existing one, so ideally your code should be structured like this, to only instantiate the text stimulus once:

text_stim = visual.TextStim(win) # only create me once

for s in symbol_choices:
    text_stim.text = s # update me as needed
    text_stim.draw()
    win.flip()
    core.wait(2)

As to the actual problem at hand, I only have a trial-and-error suggestion: problems like these are often font-specific, so try specifying different fonts for the TextStim and see what the result is.

Alternatively, try out the TextBox2 stimulus instead of TextStim. The latter relies for its actual text drawing on a third-party library called pyglet. TextBox2, meanwhile, is supported entirely by PsychoPy developers so it is more likely that issues with rendering can be addressed. For some reason, I can’t find the actual documentation for that class, but here is the link to the source code, which should make the API for creating a TextBox2 stimulus clear:

https://www.psychopy.org/_modules/psychopy/visual/textbox2/textbox2.html

thank you, changing fonts was the solution. for those who see this in the future, Menlo seemed to work well.

http://ergoemacs.org/emacs/emacs_unicode_fonts.html