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()
textFont(font, [size])

Parameters

font
Object|String:

font as a p5.Font object or a string.

size
Number:

font size in pixels.

Returns

Object: current font or p5 Object.
Notice any errors or typos? Please let us know. Please feel free to edit src/typography/loading_displaying.js and open a pull request!

Related References