Text from a variable or text file. Also optionally a box behind it.

Psychtoolbox text renderer

By default Psychtoolbox uses its own text renderer plugin. If this fails, it falls back to a more basic text renderer in your operating system and reports so in its messages at experiment startup. In this case you may see problems with text quality, alignment, or boundaries. See Psychtoolbox Screen('DrawText') for general information on text renderers, and DrawTextPlugin help for troubleshooting.

▸ Object ends on its own?

If an element can end on its own, you don't need to set end conditions for it in property end (unless you want it to maybe end earlier).

No—runs until a condition you set in property end.

Input properties

Adjustable properties

You can vary or allow the subject to adjust the following input properties of an object of this type in real time when it's running. If you need to make other properties adjustable, you can edit the element type code—see Element Type Programming Manual.





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><r>           <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><color = RGB> <cd> – color. RGB = a 1×3 RGB vector with numbers between 0–1, e.g. <cd><color = [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). This is equivalent to setting height of the "em box" for the font. Typically upper case characters are somewhat 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 setting text color.


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. This multiplies line height without affecting font size (set in fontSize above). 1 = each line's baseline is precisely fontSize distance from the next line's baseline.


Default: boxSize = no text box
Default: margin = 0.5 deg
Default: boxColor = 90% white

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.

margin sets space between the box and text edges (deg). This applies if you align text left or top, or fit the box to the text.

boxColor is a 1×3 RGB vector with numbers between 0–1 setting text box color.


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 by listing them input property report.