Text from a variable or text file. Also optional text box. Note currently text background cannot be transparent, so even if you don't use a text box, property boxColor still sets text background color.

Text renderer

The text renderer Psychtoolbox is using can have a big effect on text quality and alignment. You can check and change the text renderer with Screen('Preference', 'TextRenderer'). See Psychtoolbox Screen('DrawText') help for more information on this. On Mac, Psychtoolbox also needs GStreamer installed to use the high quality text renderer. See http://psychtoolbox.org/docs/GStreamer for more information.

For any trial you define in an experiment script, you can make one or more 


 objects using function 


Object and input them to addTrial.

For any trial you define in an experiment script, you can make one or more 


 objects using function 


Object and input them to addTrial.

Input properties

Adjustable properties

You can allow the subject to adjust the following input properties of an object of this type during the experiment using an adjuster element. If you need to make other properties adjustable, you can copy the element type using newPbType and edit it.





Default: no text

Set one of:

text is a string that is text to show.


fileName is a string that is name of text file to show. Include path if the file is not in the MATLAB current folder or search path (or not the first file with that name on the search path).

You can include the following anywhere in the text for line breaks and formatting changes.

<cd><n>           <cd> – new line (also see below)
<cd><b>           <cd> – bold
<cd><i>           <cd> – italic
<cd><u>           <cd> – underline (only on some systems and text renderers)
<cd><>            <cd> – regular (end bold/italic/underline)
<cd><font = name> <cd> – font name, e.g. <cd><font = Arial><cd>
<cd><size = n>    <cd> – font size, e.g. <cd><size = 0.8><cd>. Units are whatever you use for property fontSize below (default deg).
<cd><col = RGB>   <cd> – color. RGB = a 1×3 RGB vector with numbers between 0–1, e.g. <cd><col = [1 0 0]><cd>.

For new line you can use an array of strings with each cell containing a line (property text only), <cd><n><cd> above, character code <cd>10<cd>, or property wrapWidth to wrap lines automatically.


Default: don't wrap lines

Number of characters to wrap lines at. <cd>inf<cd> = don't wrap, but you can still use an array of strings, <cd><n><cd>, or <cd>char(10)<cd> to wrap lines manually.


Default: Arial

A string setting font. See Psychtoolbox Screen('TextFont') for more information on font names.


Default: 1 deg

This sets font size by setting line height which the font scales to (deg), not including any change in spacing from lineSpacing below. This is equivalent to setting height of the "em box" the font characters are based in. Characters (upper case) are usually a bit smaller than this. If you need more information, see Wikipedia https://en.wikipedia.org/wiki/Point_(typography) for a starting point.


Default: regular

A string <cds>"r"<cds> = regular, <cds>"b"<cds> = bold, <cds>"i"<cds> = italic, or <cds>"u"<cds> = underline.


Default: white

A 1×3 RGB vector with numbers between 0–1.


Default: center text horizontally

A string <cds>"l"<cds> = left or <cds>"c"<cds> = center to horizontally align lines.


Default: 1.3-spaced

A number: 1 = single-spaced, 2 = double, 1.5 = 1 & 1/2, etc. 1 = each line's baseline is precisely fontSize distant from the next one's.


Default: boxSize = no text box
Default: margin = 0.5 deg

boxSize sets text box size. This is a number for a square, or a vector [width height] for a rectangle (deg). Or a string <cds>"f"<cds> = fit box to text. 0 = no box (but boxColor above still sets text background color).

If you use a box and align text left or top or fit the box to the text, margin sets box space at the fit text edges (deg).


Default: same as experiment or trial background color

A 1×3 RGB vector with numbers between 0–1 setting text box or background color. <cd>[]<cd> = same as trial background color, which you can set in experiment object backColor or trial object backColor (default black). Note currently text background cannot be transparent, so boxColor sets background even if you don't want a text box.


Default: center text vertically

A string <cds>"t"<cds> = top or <cds>"c"<cds> = center to vertically align text in text box.

Input properties all visual elements have


Input properties all adjuster elements have


Input properties all objects have


Record properties

PsychBench uses record properties to record information during experiments. You can't set record properties but you can see them in experiment results using input property report.