| Reference | Downloads | Github

Some questions about the attribute "size"

I’m new to ‘psychopy’, and I want to know the attribute “size” of a stimulus and how to change the width of letters in the ‘TextStim’.
It doesn’t work if I code it like:

from psychopy import visual, core
win = visual.Window(size=(1920, 1080))
text = visual.TextStim(win, text="hello world.")

#No matter what the value it is 
text.size = (0.5, 0.5)



The height of the letters (Float/int or None = set default).

Height includes the entire box that surrounds the letters in the font. The width of the letters is then defined by the font.

Operations supported.

In API, it says that the width of the letters can only be defined by the font… So is there any alternative solution?

This is just like most other computer software. When you set the size of a font to be 12 points in your word processor, you aren’t directly setting the size of any particular character. That is all down to the font geometry itself (i.e. ‘W’ is wider than ‘I’). The point size of a font is a very indirect measure, related to the vertical spacing between lines. It just acts as an overall scaling factor, in the same way when in PsychoPy we effectively specify something similar using a variety of units. When we say the text is 1 cm high, that doesn’t mean that a G and an o will somehow become the same physical size. Their height relationship is governed by the chacteristics of the particular font itself.

So in essence, in PsychoPy, as in most other software, we can’t directly control the size of individual letters or glyphs. We can only specify an overall scaling factor for all glyphs that the font contains. And even then, our scaling factor (as with all other software) refers to a vertical scale, which is proportionately applied to width.

EDIT: but actually after re-reading your question, I’m not entirely sure what it is that you are asking. What precisely is the p[roblem that you need to solve?

Hi Michael,

Thanks for your excellent explanation! @Michael
I do have a problem with example. I need use some Chinese instruction in TextStim, for example the character "恭喜!"Then, the TextStim attached as screen shoot below. I tried different Letter height, it doesn’t change. So I need some help…
BTW, the current Font I use is “Arial”. Any other Font I can use, or any quick suggestions?

Thanks in advance,

So the problem is that the characters are being cut off? Normally when people have reported this happening with Chinese characters, the issues has been due to the font being used, and is resolved when another one is selected. Unfortunately, Arial usually seems to be the one that people have most success with, which is the opposite of your experience.

So I’d suggest experimenting with different font names. You’ll need to use exact names for the fonts, which can be found using hints here:

or here:


Sorry to disturb but I got the same problem also, did you find the solution?

Thanks in advance