0

I am super new to MatLab and I'm currently sitting in front of my computer and don't know how to solve the problem. I do plan to show my participants a string where one letter (position of the letter varies) has to be at a certain position on the screen and has a different color on the screen, letters before and letters after have to be oriented depending on the position of that letter and are in a different color (basically I try to rebuild spritz.com). So far so good, I know how to align the snippets that they dont overlap horizontally. But I do not know how to deal with letters that have a different size (for example: 'y' vs. 'd' vs. 'o'), because they will have a different position and for the participant, they do not appear to be in the same line.

So the question is, how I can align strings on a line with different sources of the string so that a y is on the same line as an o and a d. Now, that lowest pixel of every letter is on the same line but parts of the 'y' have to be kind of lower than a d for example. Thats my simplified code I've got so far:

[nxORP, nyORP, wb] = DrawFormattedText2('p',...
    'win', w1, 'sx', 960, 'sy', 553, 'xalign', 'left', 'yalign', 'bottom');

DrawFormattedText2('d',...
    'win', w1, 'sx', wb(1), 'sy', 553, 'xalign', 'right', 'yalign', 'bottom');

DrawFormattedText2('y',...
    'win', w1, 'sx', wb(3), 'sy', 553, 'xalign', 'left', 'yalign', 'bottom');

Anyone out there can help me?

PS: in the help of http://psychtoolbox.org/docs/DrawFormattedText2 I saw this: "So to use (nx,ny) as the new start position for connecting further text strings, you need to draw these strings with yPositionIsBaseline==true." but I do not know how to do this and whether this would be the solution. Any help is appreciated. All the best, Dominik

1 Answers1

0

If you use a monospaced font, then the letters will be of equal width. The fonts you have available will differ depending on your operating system, but Courier is a common monospaced font.

The font can be specified once via Screen(‘TextFont’): http://psychtoolbox.org/docs/Screen-TextFont

or as one of the formatting tags when using DrawFormattedText2: http://psychtoolbox.org/docs/DrawFormattedText2

DMR
  • 1,479
  • 1
  • 8
  • 11
  • Dear DMR, I had an error in my description. I do know how to align letters horizontally but they are not on the same vertical line. If you have ideas about that, please let me know. Thanks anyway! – Dominik Rolph Jan 23 '19 at 14:05