text

 elements

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

Text renderer

The text renderer Psychtoolbox is using is important. By default it tries to use its own high quality renderer plugin. If this fails it falls back to a lower quality renderer in your operating system but in this case you may see problems with text quality, alignment, or boundaries. See Psychtoolbox Screen('DrawText') help for general information on the text renderer. If Psychtoolbox's text renderer plugin fails, it will report it in its messages in the command window at experiment start—if so, see Psychtoolbox DrawTextPlugin help for information on fixing it.

Psychtoolbox requires GStreamer for all display functionality on Windows, or for the text renderer plugin and other specific functionality on Mac. (On Linux it's generally pre-installed.) See here for the Psychtoolbox page on GStreamer, which contains important notes. Links to the version Psychtoolbox recommends as of PTB 3.0.19 (17 Feb 2023) are below:

Windows: GStreamer 64-bit MSVC runtime 1.20.5

Mac: GStreamer runtime 1.22.0

▸ 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.

position
nn_eyes
rotation
colorMask
alpha
intensity
contrastMult

(None)

(None)

text
fileName

Default: no text

Set one of:

text is a string that is text to show.

OR

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.

wrapWidth

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.

fontName

Default: Arial

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

fontSize

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.

style

Default: regular

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

color

Default: white

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

alignment

Default: center text horizontally

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

lineSpacing

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.

boxSize
margin
boxColor

Default: boxSize = no text box
Default: margin = 0.5 deg
Default: boxColor = transparent <cd>[0 0 0 0]<cd>

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 box space at the fit 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 or 1×4 RGBA vector with numbers between 0–1 setting text box color.

vertAlignment

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

position

Input properties all adjuster elements have

adjust

Input properties all objects have

report
info

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.