text_ascent()

Returns ascent of the current font at its current size.

Examples

example picture for text_ascent()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
def setup():
    base = py5.height * 0.75
    scalar = 0.8  # different for each font

    py5.text_size(32)  # set initial text size
    a = py5.text_ascent() * scalar  # calc ascent
    py5.line(0, base-a, py5.width, base-a)
    py5.text("dp", 0, base)  # draw text on baseline

    py5.text_size(64)  # increase text size
    a = py5.text_ascent() * scalar  # recalc ascent
    py5.line(40, base-a, py5.width, base-a)
    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 Java method: textAscent

Syntax

text_ascent() -> float

Updated on September 11, 2021 16:51:34pm UTC