Some short background info. I recently landed textAscent and textDescent. What these functions do are create an offscreen processing instance, write some text to it, then measure the pixels to get the true ascent and descent values.
textAscent is the number of pixels from the bottom of the letter “t”, to the top, and the textDescent is the bottom of the letter “t” to the bottom of the letter “j”. Text leading is the space between the letter “t” and the next line’s bottom of the letter “t”. So if you were to draw the words “text/ntext” in a processing sketch, the text Leading is the number of pixels used to separate the words on the newline(\n) character.
The way processing calculates the space between two lines is by adding ascent and descent then multiplying the sum by 1.275. There is a problem with this.
I will walk you through it. You want to write some text to the screen, so you give it a size. Size has changed, so textAscent and textDescent need to be recalculated. So we call ascent and descent, which draw an offscreen canvas on which to measure pixels, which calls size, which calculates textLeading, which calls ascent and descent, which creates an offscreen canvas, which calls size, which calculates textLeading, which… you get the idea…
TextSize -> textLeading -> ascent/descent -> textSize…
I need to brainstorm a solution to this.