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().

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.
Notice any errors or typos? Please let us know. Please feel free to edit src/type/textCore.js and open a pull request!

Related References