From 43878ec09b94291942b69f106fdc78c9e140e0f8 Mon Sep 17 00:00:00 2001 From: mathewpan2 Date: Fri, 12 Apr 2024 18:24:12 -0400 Subject: [PATCH] fixed textpoint alignment --- src/typography/p5.Font.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/typography/p5.Font.js b/src/typography/p5.Font.js index e6dcbc1515..e79dea317b 100644 --- a/src/typography/p5.Font.js +++ b/src/typography/p5.Font.js @@ -344,7 +344,8 @@ p5.Font = class { textToPoints(txt, x, y, fontSize, options) { const xOriginal = x; const result = []; - + const p = this.parent; + let pos; let lines = txt.split(/\r?\n|\r|\n/g); fontSize = fontSize || this.parent._renderer._textSize; @@ -376,6 +377,14 @@ p5.Font = class { for (let l = 0; l < pts.length; l++) { pts[l].x += xoff; + pos = this._handleAlignment( + p._renderer, + line, + pts[l].x, + pts[l].y + ); + pts[l].x = pos.x; + pts[l].y = pos.y; result.push(pts[l]); } } @@ -386,7 +395,6 @@ p5.Font = class { y = y + this.parent._renderer._textLeading; } - return result; }