DrawText-trouble with bold and centering

Hi

I'm having some issues with drawing text in Psychtoolbox. I'm trying to draw a target consisting of a series of five +'s with the middle + appearing bold and slightly larger than the others. However, the bold + appears smaller than the other +'s even though it has a larger font size. The other issue is that the middle + and the other +'s can't seem to be vertically aligned. I've tried using the 'center' option on DrawFormattedText as well as manually specifying the x,y locations, but the middle + always seems either a little above or a little below the other +'s. I've been using Helvetica font (if possible, I'd like to stay with Helvetica) and changing the font styles, sizes using the Screen('TextStyle') and Screen('Textsize') commands.

Thanks for your help,
Channing Chang
Could you give us some minimal (as few lines as possible) code that demostrated the problem?
If you only need + symbols, why not just draw two lines to make the cross? I think for text the baseline of the characters is aligned, not their center. I'm not sure if there is a switch to change that. See if you see the word baseline in some of the text functions.
Best,
Dee

On Tue, Jan 24, 2012 at 04:25, channing_chang07 <channing_chang07@...> wrote:

Hi

I'm having some issues with drawing text in Psychtoolbox. I'm trying to draw a target consisting of a series of five +'s with the middle + appearing bold and slightly larger than the others. However, the bold + appears smaller than the other +'s even though it has a larger font size. The other issue is that the middle + and the other +'s can't seem to be vertically aligned. I've tried using the 'center' option on DrawFormattedText as well as manually specifying the x,y locations, but the middle + always seems either a little above or a little below the other +'s. I've been using Helvetica font (if possible, I'd like to stay with Helvetica) and changing the font styles, sizes using the Screen('TextStyle') and Screen('Textsize') commands.

Thanks for your help,
Channing Chang


--- In psychtoolbox@yahoogroups.com, "Diederick C. Niehorster" <dcnieho@...> wrote:

> If you only need + symbols, why not just draw two lines to make the cross?
> I think for text the baseline of the characters is aligned, not their
> center.

Also, bold faces are usually not dilations in the sense of https://en.wikipedia.org/wiki/Dilation_(morphology) and you can normally not use a bold face to outline a normal face. In particular a bold face is drafted with thicker stems, keeping x-height and other dimensions the same (it's aesthetic not mathematical).

So drawing a cross would surely be more straight-forward.

--Tobias
Thanks for your responses. The code looks something like this:

winRect = Screen('Rect', wPtr);
Screen('TextFont',wPtr, 'Helvetica');
Screen('TextStyle',wPtr, 1);
Screen('TextSize',wPtr, 26);
bbox=Screen('TextBounds', wPtr, '+');
Screen('DrawText',wPtr,'+',winRect(3)/2-bbox(3)/2,winRect(4)/2-bbox(4)/2,color);
Screen('TextStyle',wPtr, 0);
Screen('TextSize',wPtr, 24);
bbox2=Screen('TextBounds', wPtr, '++ ++');
Screen('DrawText',wPtr,'++ ++',winRect(3)/2-bbox2(3)/2,winRect(4)/2-bbox2(4)/2,color);

I adjusted the code slightly to make it more readable, but basically, I draw the middle and other four crosses separately, and center them by subtracting the x,y values of the center by the half the dimensions of the textbox.The middle cross is set to a larger font, and set as bold.

Drawing the crosses using lines sounds great, but we're trying to transfer a experiment that we wrote on another software, where we drew the crosses using text, over to Psychtoolbox. If possible, we'd like to keep it similar and stay with text.

Thanks,
Channing

--- In psychtoolbox@yahoogroups.com, "T Wolf" <ptb.mail.reflector@...> wrote:
>
> --- In psychtoolbox@yahoogroups.com, "Diederick C. Niehorster" <dcnieho@> wrote:
>
> > If you only need + symbols, why not just draw two lines to make the cross?
> > I think for text the baseline of the characters is aligned, not their
> > center.
>
> Also, bold faces are usually not dilations in the sense of https://en.wikipedia.org/wiki/Dilation_(morphology) and you can normally not use a bold face to outline a normal face. In particular a bold face is drafted with thicker stems, keeping x-height and other dimensions the same (it's aesthetic not mathematical).
>
> So drawing a cross would surely be more straight-forward.
>
> --Tobias
>