psychopy.org | Reference | Downloads | Github

How to horizontally align fixation cross with letter (not its bounding box)?

Hi all,

is there an ‘easy’ way to horizontally align a fixation cross with a letter (TextStim using a font)?
And I mean the actual letter and not its bounding box.

I want to present a fixation cross on the center of the screen, and a letter on the right of it, in a way that an (imaginary) straight, perfectly horizontal, line would connect the center of the fixation cross and the center of the letter presented on the right?

best regards,
koen

How do you define the centre of a letter? I’m not sure you can do better than a bounding box. Fonts themselves align characters vertically upon a baseline rather than on any concept of a centre.

Given the variability in fonts, and the variability of letters within a font, I think you should do this by creating an image of your letter which you can then align perfectly

Thank you for your replies Michael and Jon.
I think I might have found a way.
In a first step, I defined the position of the bounding box.
I drew the bounding box of a letter on the screen, and had a program return the positions (x,y) of all pixels used for drawing this square. Now you have the extremes, allowing you to define the centre of the bounding box, both on the x- and y-axis.
In a second step, a letter was drawn on the screen, and a program returned the x,y coordinates of all pixels used. Now you have the extremes, allowing you to define the centre of the letter and how far it is off from the centre of the bounding box, which is where I wanted to align with (same centre on the y-axis as a centrally presented fixation dot). So, you can adjust it accordingly.