Py5Font.ascent()

Py5Font.ascent()

Get the ascent of this font from the baseline.

Examples

example picture for ascent()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
def setup():
    font_size = 45
    font = py5.create_font('DejaVu Sans', font_size)
    py5.text_font(font)

    baseline = py5.height / 2
    ascent = baseline - font.ascent() * font_size
    descent = baseline + font.descent() * font_size

    py5.text("py5", 10, baseline)
    py5.line(0, ascent, py5.width, ascent)
    py5.line(0, baseline, py5.width, baseline)
    py5.line(0, descent, py5.width, descent)

Description

Get the ascent of this font from the baseline. The value is based on a font of size 1. Multiply it by the font size to get the offset from the baseline.

Underlying Processing method: PFont.ascent

Syntax

ascent() -> float

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