# SCREEN &#39;DrawText&#39; clipping bug

**URL:** https://psychtoolbox.discourse.group/t/screen-39-drawtext-39-clipping-bug/318
**Category:** Uncategorized
**Created:** [June 5, 2013, 10:02pm UTC](https://psychtoolbox.discourse.group/t/screen-39-drawtext-39-clipping-bug/318 "2013-06-05T22:02:24Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![denispelli](https://avatars.discourse-cdn.com/v4/letter/d/cdc98d/32.png) [@denispelli](https://psychtoolbox.discourse.group/u/denispelli)
#### Post date: [June 5, 2013, 10:02pm UTC](https://psychtoolbox.discourse.group/t/screen-39-drawtext-39-clipping-bug/318/1 "2013-06-05T22:02:24Z")

</div>

% 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](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;

 ![Inline image 1](cid:ii_13f16577426841be) ![Inline image 1](cid:ii_13f165449241a9de)  

  

  

Denis Pelli

Professor of Psychology and Neural Science at New York University

[http://psych.nyu.edu/pelli/](http://psych.nyu.edu/pelli/)

[http://denispelli.com](http://denispelli.com)

[denis.pelli@...](mailto:denis.pelli@...)
