Skip to content

textSize()

Sets the font size when text() is called, or gets the font size if no argument given.

Note: Font size is measured in pixels.

Examples

textSize example 1

require("L5")

function setup()
  size(100, 100)

  background(200)

  -- Top.
  textSize(12)
  text('Font Size 12', 10, 30)

  -- Middle.
  textSize(14)
  text('Font Size 14', 10, 60)

  -- Bottom.
  textSize(16)
  text('Font Size 16', 10, 90)

  describe('The text "Font Size 12" drawn small, "Font Size 14" drawn medium, and "Font Size 16" drawn large.')
end

Syntax

textSize(size)
textSize()

Parameters

Parameter
size Number: size of the letters in units of pixels.

Returns

Number: If no argument given, returns size of a letter in current font, in units of pixels.


This reference page contains content adapted from p5.js and Processing by p5.js Contributors and Processing Foundation, licensed under CC BY-NC-SA 4.0.