Reference textFont()

textFont()

Sets the font used by the text() function.

The first parameter, font, sets the font. textFont() recognizes either a p5.Font object or a string with the name of a system font. For example, 'Courier New'.

The second parameter, size, is optional. It sets the font size in pixels. This has the same effect as calling textSize().

Calling textFont() without arguments returns the current font.

Note: WEBGL mode only supports fonts loaded with loadFont().

Examples

Syntax

textFont([font], [size])

Parameters

font
p5.Font|String|Object: The font to apply
size
Number: An optional text size to apply.

Returns

String|p5.Font: If no arguments are provided, returns the current font

Related References