Py5Font.ascent()#

Get the ascent of this font from the baseline.

Examples#

example picture for ascent()
 1def setup():
 2    font_size = 45
 3    font = py5.create_font('DejaVu Sans', font_size)
 4    py5.text_font(font)
 5
 6    baseline = py5.height / 2
 7    ascent = baseline - font.ascent() * font_size
 8    descent = baseline + font.descent() * font_size
 9
10    py5.text("py5", 10, baseline)
11    py5.line(0, ascent, py5.width, ascent)
12    py5.line(0, baseline, py5.width, baseline)
13    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