Hello,
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.")
text.draw()
win.flip()
core.wait(2)
#No matter what the value it is
text.size = (0.5, 0.5)
text.draw()
win.flip()
core.wait(2)
core.quit()
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?
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?
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:
Thank you so much for the help and advice. It worked.
I would like to know whether the responses given by the participants using the slider would be saved in a csv file? In the Data tab of slider, “store rating” is enabled. I want to store the responses according to the serial number of the trials as they (trials) are placed in the condition file. For example, 5 responses in 5 columns for trial 1 (this trial 1 is the first stimulus in the condition file). Please advise.