text_leading()#

Sets the spacing between lines of text in units of pixels.

Examples#

example picture for text_leading()
 1def setup():
 2    # text to display. the "\n" is a "new line" character
 3    lines_of_text = "L1\nL2\nL3"
 4    py5.text_size(12)
 5    py5.fill(0)  # set fill to black
 6
 7    py5.text_leading(10)  # set leading to 10
 8    py5.text(lines_of_text, 10, 25)
 9
10    py5.text_leading(20)  # set leading to 20
11    py5.text(lines_of_text, 40, 25)
12
13    py5.text_leading(30)  # set leading to 30
14    py5.text(lines_of_text, 70, 25)

Description#

Sets the spacing between lines of text in units of pixels. This setting will be used in all subsequent calls to the text() function. Note, however, that the leading is reset by text_size(). For example, if the leading is set to 20 with text_leading(20), then if text_size(48) is run at a later point, the leading will be reset to the default for the text size of 48.

Underlying Processing method: textLeading

Syntax#

text_leading(leading: float, /) -> None

Parameters#

  • leading: float - the size in pixels for spacing between lines

Updated on November 12, 2021 11:30:58am UTC