Skip to content

Commit 539fb30

Browse files
authored
Merge pull request #6967 from mathewpan2/TextToPoint-alignment
fixed textpoint alignment
2 parents e624307 + 43878ec commit 539fb30

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/typography/p5.Font.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ p5.Font = class {
344344
textToPoints(txt, x, y, fontSize, options) {
345345
const xOriginal = x;
346346
const result = [];
347-
347+
const p = this.parent;
348+
let pos;
348349
let lines = txt.split(/\r?\n|\r|\n/g);
349350
fontSize = fontSize || this.parent._renderer._textSize;
350351

@@ -376,6 +377,14 @@ p5.Font = class {
376377

377378
for (let l = 0; l < pts.length; l++) {
378379
pts[l].x += xoff;
380+
pos = this._handleAlignment(
381+
p._renderer,
382+
line,
383+
pts[l].x,
384+
pts[l].y
385+
);
386+
pts[l].x = pos.x;
387+
pts[l].y = pos.y;
379388
result.push(pts[l]);
380389
}
381390
}
@@ -386,7 +395,6 @@ p5.Font = class {
386395

387396
y = y + this.parent._renderer._textLeading;
388397
}
389-
390398
return result;
391399
}
392400

0 commit comments

Comments
 (0)