psychopy.org | Reference | Downloads | Github

PsychoPy.visual.textStim can not display monotype corsiva correctly

I am programming a research experiment to presenting participants with text snippets in different fonts, and one text font is not dissplay properly. When presenting Monotype Corsiva the characters are being cut off strangely (see the screenshot below). Does anyone have a workaround, or any suggestions on how to fix this? Full disclosure, I can run the script perfectly on my mac, but the equipment im using for the experiment is windows based.

I am running this code on a windows 10 psychoPy v1.85.4:

# -*- coding: utf-8 -*-

# Import the PsychoPy libraries that you want to use
from __future__ import absolute_import, division
from psychopy import locale_setup, gui, visual, core, data, event, logging
from psychopy.constants import (NOT_STARTED, STARTED, PLAYING, PAUSED, STOPPED, FINISHED, PRESSED, RELEASED, FOREVER)
from psychopy.tools.filetools import fromFile, toFile
import numpy as np  # whole numpy lib is available, prepend 'np.'
from numpy import (sin, cos, tan, log, log10, pi, average,
                   sqrt, std, deg2rad, rad2deg, linspace, asarray)
from numpy.random import random, randint, normal, shuffle
from psychopy.iohub import EventConstants, ioHubExperimentRuntime, module_directory, getCurrentDateTimeString
import os  # handy system and path functions
import sys  # to get file system encoding
import csv


############################################################
win = visual.Window(
    [1440, 900], 
    [1, 1, 1] ,
    color=(1, 1, 1), 
    fullscr=True, 
    colorSpace='rgb',
    blendMode='avg',
    monitor="testMonitor",
    units='norm')


# Initialize components for Routine "instructPractice"
instr1 = visual.TextStim(win=win, name='instr1',
    text="Some long instruction text",
    font='Monotype Corsiva',
    pos=[0, 0], height=0.06, wrapWidth=20, ori=0, 
    color='black', colorSpace='rgb', opacity=1,
    depth=0.0)

# make instruction appear until key event
instr1.draw()
win.flip()
#self.hub.sendMessageEvent(text="instructions_start",sec_time=flip_time)
if 'escape' in event.waitKeys():
    core.quit()

I can see that too but not sure what we can do about it. The text is rendered by the pyglet library and I guess the problem is that this font has a particularly extreme italic form but the pyglet library doesn’t have a way for us to extend the “kerning” (the gap between the letters).

I’m afraid you’ll just have to save images with your text on them instead! :slightly_frowning_face:

Damn, I had my hopes so high. There is no manuel way to expand/increase the kerning?

Pyglet’s TextLayout class seems to have a kerning parameter documented here.

If it were me I would test out that text sample in Pyglet without using PsychoPy to see if I could make it do what I wanted then go back and fix PsychoPy using what I learned. The fewer layers in the way when grappling with a problem at first the better.

- Allen

1 Like