Skip to content

Commit

Permalink
Merge pull request #6967 from mathewpan2/TextToPoint-alignment
Browse files Browse the repository at this point in the history
fixed textpoint alignment
  • Loading branch information
limzykenneth authored Sep 22, 2024
2 parents e624307 + 43878ec commit 539fb30
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/typography/p5.Font.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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]);
}
}
Expand All @@ -386,7 +395,6 @@ p5.Font = class {

y = y + this.parent._renderer._textLeading;
}

return result;
}

Expand Down

0 comments on commit 539fb30

Please sign in to comment.