text_ascent()#

Returns ascent of the current font at its current size.

Examples#

example picture for text_ascent()
 1def setup():
 2    base = py5.height * 0.75
 3    scalar = 0.8  # different for each font
 4
 5    py5.text_size(32)  # set initial text size
 6    a = py5.text_ascent() * scalar  # calc ascent
 7    py5.line(0, base-a, py5.width, base-a)
 8    py5.text("dp", 0, base)  # draw text on baseline
 9
10    py5.text_size(64)  # increase text size
11    a = py5.text_ascent() * scalar  # recalc ascent
12    py5.line(40, base-a, py5.width, base-a)
13    py5.text("dp", 40, base)  # draw text on baseline

Description#

Returns ascent of the current font at its current size. This information is useful for determining the height of the font above the baseline.

Underlying Processing method: textAscent

Syntax#

text_ascent() -> float

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