Reference textAscent()

textAscent()

Returns the ascent of the text.

The textAscent() function calculates the distance from the baseline to the highest point of the current font. This value represents the ascent, which is essential for determining the overall height of the text along with textDescent(). If a text string is provided as an argument, the ascent is calculated based on that specific string; otherwise, the ascent of the current font is returned.

Examples

Syntax

textAscent([txt])

Parameters

txt
String: (Optional) The text string for which to calculate the ascent. If omitted, the function returns the ascent for the current font.

Returns

Number: The ascent value in pixels.
Notice any errors or typos? Please let us know. Please feel free to edit src/type/textCore.js and open a pull request!

Related References