Skip to content

Commit

Permalink
fixed textpoint alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
mathewpan2 committed Apr 12, 2024
1 parent 8e1810f commit 43878ec
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 43878ec

Please sign in to comment.