In that case vertical aligning calculates wrong

here is the example:
const s = 'Theeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeelazydog.';
function setup() {
createCanvas(200, 100);
}
function draw() {
background(220);
textAlign(CENTER, CENTER)
textSize(22);
text(s, 0, 0, 200, 100);
}
Welcome! 馃憢 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already.
From what I understand this seems to be an issue in the library code here.
Since the textWidth (the actual width of the text ) turns out to be more than the provided width, the intention here was to increase the totalHeight of the line and to break up the text into multiple lines as seen in this sketch.
https://editor.p5js.org/akshay_07cf/sketches/ae-zLrbff
But since here we just have one big word "Theeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeelazydog", it is not split into two lines, but the height is still adjusted. This causes the issue.
Seems like it. Maybe we can at least check if n > 1 before increasing totalHeight? 馃
Or if n == 1 split it into two parts
That could still cause issues if the longer word comes later in a sentence. Like in this sketch https://editor.p5js.org/akshay_07cf/sketches/bhpN46kAX
What I thought was to keep a track of the number of words added so far in testLine, I saw it resets every time a split happens. So if testLine only has one word i.e the current line only has one word, don't adjust the height.
@lmccart @limzykenneth I will go ahead and patch this?
@akshay-99 Sounds good, do go ahead. I'll assign the issue to you.
Most helpful comment
That could still cause issues if the longer word comes later in a sentence. Like in this sketch https://editor.p5js.org/akshay_07cf/sketches/bhpN46kAX
What I thought was to keep a track of the number of words added so far in
testLine, I saw it resets every time a split happens. So iftestLineonly has one word i.e the current line only has one word, don't adjust the height.