From 6d3dd45c0c603a4c5cc7c152ecfcc9f7964407e7 Mon Sep 17 00:00:00 2001 From: Tiancheng Geng <221900006@smail.nju.edu.cn> Date: Sat, 21 Dec 2024 07:55:28 +0800 Subject: [PATCH] fix: text() swallows characters in CHAR wrap mode #7437 --- src/core/p5.Renderer.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core/p5.Renderer.js b/src/core/p5.Renderer.js index 21ce3bd64b..a08966639e 100644 --- a/src/core/p5.Renderer.js +++ b/src/core/p5.Renderer.js @@ -390,9 +390,9 @@ class Renderer extends p5.Element { line = `${chars[charIndex]}`; } } + nlines.push(line); } - nlines.push(line); let offset = 0; if (this._textBaseline === constants.CENTER) { offset = (nlines.length - 1) * p.textLeading() / 2; @@ -423,16 +423,16 @@ class Renderer extends p5.Element { line = `${chars[charIndex]}`; } } + this._renderText( + p, + line.trim(), + x, + y - offset, + finalMaxHeight, + finalMinHeight + ); + y += p.textLeading(); } - this._renderText( - p, - line.trim(), - x, - y - offset, - finalMaxHeight, - finalMinHeight - ); - y += p.textLeading(); } } else { // Offset to account for vertically centering multiple lines of text - no