textFont()

Category:Drawing

Sets the current font.

This font will be used in all subsequent calls to text(). The default font is Arial. The parameter must be a string representing a web safe font. See W3 Schools - Web Safe Fonts

Text that does not fit completely within the display area will not be drawn or seen.

Examples

// Various fonts.
textSize(18);
text("Hello World", 100, 75);
textFont("Arial");  // Same as default font.
text("Hello World", 100, 125);
textFont("Georgia");
text("Hello World", 100, 175);
textFont("Times New Roman");
text("Hello World", 100, 225);
textFont("Courier New");
text("Hello World", 100, 275);

Syntax

textFont(font);

Parameters

Name Type Required? Description
font String A string representing a web safe font.

Returns

No return value. Changes future text output to the display only.

Found a bug in the documentation? Let us know at documentation@code.org