Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Commit

Permalink
fix: Fix line y-position computation bug (#17)
Browse files Browse the repository at this point in the history
Fixes #11
  • Loading branch information
bluepichu authored and tleunen committed Dec 31, 2016
1 parent 47ef20c commit 6aa7636
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pixi-multistyle-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ class MultiStyleText extends PIXI.Text {
this.context.textBaseline = "alphabetic";
this.context.lineJoin = "round";

let basePositionY = 0;

// Draw the text
for (let i = 0; i < outputTextData.length; i++) {
let line = outputTextData[i];
Expand All @@ -246,7 +248,7 @@ class MultiStyleText extends PIXI.Text {
this.context.lineWidth = textStyle.strokeThickness;

linePositionX += maxStrokeThickness / 2;
let linePositionY = (maxStrokeThickness / 2 + i * lineHeights[i]) + fontProperties.ascent;
let linePositionY = (maxStrokeThickness / 2 + basePositionY) + fontProperties.ascent;

if (this._style.align === "right") {
linePositionX += maxLineWidth - lineWidths[i];
Expand Down Expand Up @@ -308,6 +310,8 @@ class MultiStyleText extends PIXI.Text {
linePositionX += line[j].width;
linePositionX -= maxStrokeThickness / 2;
}

basePositionY += lineHeights[i];
}

this.updateTexture();
Expand Down

0 comments on commit 6aa7636

Please sign in to comment.