textSize()

Category:Drawing

Sets/gets the current font size.

This size will be used in all subsequent calls to text(). Font size is measured in pixels and tThe default font size is 12 pixels. Text that does not fit completely within the display area will not be drawn or seen.

Examples

// Display various font sizes.
textSize(12);
text("Font Size "+textSize(), 10, 30);
textSize(16);
text("Font Size "+textSize(), 10, 60);
textSize(25);
text("Font Size "+textSize(), 10, 90);

Syntax

textSize(pixels);

Parameters

NameTypeRequired?Description
pixels Number The number of pixels for the height of the text. Should be a positive number.

Returns

The current text size in pixels. Also changes future text output to the display.

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