% DrawTextClipBug.m
% June 5, 2013, Denis Pelli
% This short program demonstrates a bug in Psychtoolbox SCREEN 'DrawText'.
% I have pasted screen shots, below, of the clipped display by SCREEN, and
% the unclipped normal display in Microsoft Word. I'm not sure whether the screen shots will
% be allowed by Yahoo, so my explanation, below, does not rely on the images.
% The problem is only manifest in fonts that extend well beyond their
% nominal size. The Linotype font "KuenstlerScript LT TwoBold" is a lacy
% script. The capital letters have long flourishes that are meant to
% overlap nearby letters. When I ask DrawText to render a capital letter
% from this font, the resulting letter is clipped on the top and on the
% right. Adding several spaces to the right of the single capital letter,
% e.g. 'K ' in the string provided to DrawString overcomes the
% right-side clipping, but I can't think of any way to overcome the topside
% clipping. Note that Kuenstler is a high quality font and renders without
% clipping in other programs, e.g. Microsoft Word. For testing purposes,
% I've placed a copy of the font on my website:
http://psych.nyu.edu/pelli/docs/kuenstler.zip
% I'm hoping that Mario can fix SCREEN DrawText to draw Kuenstler
% without clipping. Thanks. Denis
textFont='Georgia'; % The 'Georgia' font works fine, no clipping.
textFont='KuenstlerScript LT TwoBold'; % The Kuenstler font is clipped by DrawText.
window = Screen('OpenWindow', 0);
screenRect=Screen('Rect', window);
message=sprintf('%s. Click to exit.',textFont);
SCREEN(window,'TextSize',24);
SCREEN(window,'DrawText',message,200,screenRect(4)-50);
SCREEN(window,'TextFont',textFont);
screenFont=SCREEN(window,'TextFont');
if ~strcmp(screenFont,textFont)
clear screen; ShowCursor;
error('Sorry, can''t find font ''%s''.',textFont)
end
SCREEN(window,'TextSize',200);
[x0,y0]=RectCenter(screenRect);
SCREEN(window,'DrawText','K',x0,y0);
Screen('Flip', window);
GetClicks;
clear screen;