Psychtoolbox - Text for Instruction [closed]

2019-08-03 09:54发布

问题:

I have some problems using Psychtoolbox Screen and Textwindow... For my experiment I want to give an instruction at the beginning. I used something like this: % Draw text in the middle of the screen in Courier in white

Screen('TextSize', window, 20);
Screen('TextFont', window, 'Courier');
DrawFormattedText(window, 'Hello World', 'center', 'center', white);

And the other basic Screen definitions. The problem is: The text is not fully shown. I tried different sizes and set the Font to Times, but it is always the same - every letter is only displayed 3/4 (ca)...

What could be the problem? Would be very nice if someone can give me a hint...

Thanks!

回答1:

Can you describe what you mean by 'every letter is only displayed 3/4 (ca)"? The code you posted looks correct. For example, here is that code, with the addition of some set-up routines, and taking and saving a screenshot as "testImage.png", with the screen shot attached.

screenNum = max(Screen('Screens'));
window = Screen('OpenWindow', screenNum, 0);
white = WhiteIndex(window);
Screen('TextSize', window, 20);
Screen('TextFont', window, 'Courier');
DrawFormattedText(window, 'Hello World', 'center', 'center', white)
Screen('Flip', window);
imageArray = Screen('GetImage', window);
WaitSecs(3);
Screen('CloseAll');
imwrite(imageArray, 'testImage.png');



回答2:

I found the problem... Just a dumb mistake in my long Code. I have set the Font and Size of Text earlier, and this interfered with this new text features. Nevertheless, thank you for your help!