Outlines around text when text is drawn with DrawFormattedText or DrawText

Greetings.

I'm having trouble with DrawFormattedText / DrawText. If I want to draw words using either one of these functions, they will draw an outline around each letter as though it were a pen stroke. Problem is, there is no argument within either function that allows pen width to be manipulated.

My advisor was told that this is a consequence of font smoothing, and that there's an option to turn off font smoothing for text sizes 12 and smaller. However, our text size needs to be around 22. Does anyone know a trick that will get rid of this outline for font sizes that exceed 12?

Thank you,
Mouna

P.S. You can see these outlines clearly if you draw text that is low-contrast with the background. If you're interested, I've written a program below that does just that.



function Text

% Programmer: Mouna Attarha
% Started: January 2012

% DESCRIPTION: Presents text on the screen.

%--------------------------%
%%%%% define variables %%%%%
%--------------------------%

% Timing
frameDuration = .400;

%---------------------------%
%%%%% initialize screen %%%%%
%---------------------------%

% Open windows and run

% Basic setup stuff
AssertOpenGL;

% This sets a PTB preference to skip some timing tests. A value of 0
% runs these tests, and a value of 1 inhibits them. This should be set
% to 0 for actual experiments, since it can detect timing problems.
Screen('Preference', 'SkipSyncTests', 0);

% The next line sets a PTB preference to vary the amount of testing
% that PTB does when it first opens a window. Higher values lead to
% more testing and debugging, lower values lead to less. 3 seems to be
% a good level: it reports any major problems but doesn't waste a lot
% of time.
Screen('Preference', 'VisualDebugLevel', 5);

% This opens the screen window and places it on the secondary monitor,
% if there is one
ScreenVector = Screen('Screens');
[MainWindow, screenRect] = Screen('OpenWindow', max(ScreenVector), 0, [], 32, 2);
Screen('BlendFunction', MainWindow, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
interFrameInterval = Screen('GetFlipInterval', MainWindow); % get refresh interval

%-----------------------------------------------------------%
%%%%% variables that depend on screen being initialized %%%%%
%-----------------------------------------------------------%

% Colors
midGray = [128 128 128];
red = [150 128 128];

%-------------%
%%%%% run %%%%%
%-------------%

ListenChar(2); % this suppresses output of keypresses in the command window
HideCursor; % this hides the cursor

% Initialize timing for flipping
vbl = GetSecs;

% Set screen to gray
Screen('FillRect', MainWindow, midGray);

% Set the text size
Screen('TextSize', MainWindow, 55);

% Draw and show the text
[nx, ny, textbounds] = DrawFormattedText(MainWindow, 'why is this text outlined?', 'center', 'center', red, [], [], [], [], []);
[vbl, sTime, lastEventTime] = Screen('Flip', MainWindow, vbl + frameDuration);

% Wait until a key is pressed
KbWait;

% Close windows and reactivate keyboard
Screen('CloseAll');
ListenChar(0);
Maybe it is the default font problem. It won't show outlines on my computer. You could try to add Screen('TextFont') line to specify a different font.

-Xiangrui

--- In psychtoolbox@yahoogroups.com, "Mouna Attarha" <mouna_a101@...> wrote:
>
> Greetings.
>
> I'm having trouble with DrawFormattedText / DrawText. If I want to draw words using either one of these functions, they will draw an outline around each letter as though it were a pen stroke. Problem is, there is no argument within either function that allows pen width to be manipulated.
>
> My advisor was told that this is a consequence of font smoothing, and that there's an option to turn off font smoothing for text sizes 12 and smaller. However, our text size needs to be around 22. Does anyone know a trick that will get rid of this outline for font sizes that exceed 12?
>
> Thank you,
> Mouna
>
> P.S. You can see these outlines clearly if you draw text that is low-contrast with the background. If you're interested, I've written a program below that does just that.
>
>
>
> function Text
>
> % Programmer: Mouna Attarha
> % Started: January 2012
>
> % DESCRIPTION: Presents text on the screen.
>
> %--------------------------%
> %%%%% define variables %%%%%
> %--------------------------%
>
> % Timing
> frameDuration = .400;
>
> %---------------------------%
> %%%%% initialize screen %%%%%
> %---------------------------%
>
> % Open windows and run
>
> % Basic setup stuff
> AssertOpenGL;
>
> % This sets a PTB preference to skip some timing tests. A value of 0
> % runs these tests, and a value of 1 inhibits them. This should be set
> % to 0 for actual experiments, since it can detect timing problems.
> Screen('Preference', 'SkipSyncTests', 0);
>
> % The next line sets a PTB preference to vary the amount of testing
> % that PTB does when it first opens a window. Higher values lead to
> % more testing and debugging, lower values lead to less. 3 seems to be
> % a good level: it reports any major problems but doesn't waste a lot
> % of time.
> Screen('Preference', 'VisualDebugLevel', 5);
>
> % This opens the screen window and places it on the secondary monitor,
> % if there is one
> ScreenVector = Screen('Screens');
> [MainWindow, screenRect] = Screen('OpenWindow', max(ScreenVector), 0, [], 32, 2);
> Screen('BlendFunction', MainWindow, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
> interFrameInterval = Screen('GetFlipInterval', MainWindow); % get refresh interval
>
> %-----------------------------------------------------------%
> %%%%% variables that depend on screen being initialized %%%%%
> %-----------------------------------------------------------%
>
> % Colors
> midGray = [128 128 128];
> red = [150 128 128];
>
> %-------------%
> %%%%% run %%%%%
> %-------------%
>
> ListenChar(2); % this suppresses output of keypresses in the command window
> HideCursor; % this hides the cursor
>
> % Initialize timing for flipping
> vbl = GetSecs;
>
> % Set screen to gray
> Screen('FillRect', MainWindow, midGray);
>
> % Set the text size
> Screen('TextSize', MainWindow, 55);
>
> % Draw and show the text
> [nx, ny, textbounds] = DrawFormattedText(MainWindow, 'why is this text outlined?', 'center', 'center', red, [], [], [], [], []);
> [vbl, sTime, lastEventTime] = Screen('Flip', MainWindow, vbl + frameDuration);
>
> % Wait until a key is pressed
> KbWait;
>
> % Close windows and reactivate keyboard
> Screen('CloseAll');
> ListenChar(0);
>
Screen('Preference', 'TextAntiAliasing', 0);

...will disable text anti-aliasing, which should solve your problem.
-mario

--- In psychtoolbox@yahoogroups.com, "Mouna Attarha" <mouna_a101@...> wrote:
>
> Greetings.
>
> I'm having trouble with DrawFormattedText / DrawText. If I want to draw words using either one of these functions, they will draw an outline around each letter as though it were a pen stroke. Problem is, there is no argument within either function that allows pen width to be manipulated.
>
> My advisor was told that this is a consequence of font smoothing, and that there's an option to turn off font smoothing for text sizes 12 and smaller. However, our text size needs to be around 22. Does anyone know a trick that will get rid of this outline for font sizes that exceed 12?
>
> Thank you,
> Mouna
>
> P.S. You can see these outlines clearly if you draw text that is low-contrast with the background. If you're interested, I've written a program below that does just that.
>
>
>
> function Text
>
> % Programmer: Mouna Attarha
> % Started: January 2012
>
> % DESCRIPTION: Presents text on the screen.
>
> %--------------------------%
> %%%%% define variables %%%%%
> %--------------------------%
>
> % Timing
> frameDuration = .400;
>
> %---------------------------%
> %%%%% initialize screen %%%%%
> %---------------------------%
>
> % Open windows and run
>
> % Basic setup stuff
> AssertOpenGL;
>
> % This sets a PTB preference to skip some timing tests. A value of 0
> % runs these tests, and a value of 1 inhibits them. This should be set
> % to 0 for actual experiments, since it can detect timing problems.
> Screen('Preference', 'SkipSyncTests', 0);
>
> % The next line sets a PTB preference to vary the amount of testing
> % that PTB does when it first opens a window. Higher values lead to
> % more testing and debugging, lower values lead to less. 3 seems to be
> % a good level: it reports any major problems but doesn't waste a lot
> % of time.
> Screen('Preference', 'VisualDebugLevel', 5);
>
> % This opens the screen window and places it on the secondary monitor,
> % if there is one
> ScreenVector = Screen('Screens');
> [MainWindow, screenRect] = Screen('OpenWindow', max(ScreenVector), 0, [], 32, 2);
> Screen('BlendFunction', MainWindow, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
> interFrameInterval = Screen('GetFlipInterval', MainWindow); % get refresh interval
>
> %-----------------------------------------------------------%
> %%%%% variables that depend on screen being initialized %%%%%
> %-----------------------------------------------------------%
>
> % Colors
> midGray = [128 128 128];
> red = [150 128 128];
>
> %-------------%
> %%%%% run %%%%%
> %-------------%
>
> ListenChar(2); % this suppresses output of keypresses in the command window
> HideCursor; % this hides the cursor
>
> % Initialize timing for flipping
> vbl = GetSecs;
>
> % Set screen to gray
> Screen('FillRect', MainWindow, midGray);
>
> % Set the text size
> Screen('TextSize', MainWindow, 55);
>
> % Draw and show the text
> [nx, ny, textbounds] = DrawFormattedText(MainWindow, 'why is this text outlined?', 'center', 'center', red, [], [], [], [], []);
> [vbl, sTime, lastEventTime] = Screen('Flip', MainWindow, vbl + frameDuration);
>
> % Wait until a key is pressed
> KbWait;
>
> % Close windows and reactivate keyboard
> Screen('CloseAll');
> ListenChar(0);
>