Skip to content

Commit

Permalink
Merge branch 'dev' into release/2.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
uguraslan committed Apr 11, 2024
2 parents 9a35ac6 + c3780e5 commit 0d399b2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/src-to-dist.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ console.log("Copying all JavaScript source code to ./dist...");
shell.find('./src/')
.filter(file => {
const ext = path.extname(file);
return ['.js', '.mjs', '.d.mts', '.d.ts'].includes(ext) && !file.includes('.test.');
return ['.js', '.mjs', '.mts', '.ts'].includes(ext) && !file.includes('.test.');
})
.forEach(file => {
const distFile = path.join('./dist', file);
Expand Down
14 changes: 14 additions & 0 deletions src/textures/TextTexture.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,17 @@ export default class TextTexture extends Texture {
return this._textIndent;
}

set rtl(v) {
if (this._rtl !== v) {
this._rtl = v;
this._changed();
}
}

get rtl() {
return this._rtl;
}

get precision() {
return super.precision;
}
Expand Down Expand Up @@ -620,6 +631,7 @@ export default class TextTexture extends Texture {
if (this.highlightPaddingRight !== 0) nonDefaults["highlightPaddingRight"] = this.highlightPaddingRight;
if (this.letterSpacing !== 0) nonDefaults["letterSpacing"] = this.letterSpacing;
if (this.textIndent !== 0) nonDefaults["textIndent"] = this.textIndent;
if (this.rtl !== 0) nonDefaults["rtl"] = this.rtl;

if (this.cutSx) nonDefaults["cutSx"] = this.cutSx;
if (this.cutEx) nonDefaults["cutEx"] = this.cutEx;
Expand Down Expand Up @@ -667,6 +679,7 @@ export default class TextTexture extends Texture {
obj.highlightPaddingRight = this._highlightPaddingRight;
obj.letterSpacing = this._letterSpacing;
obj.textIndent = this._textIndent;
obj.rtl = this._rtl;
obj.cutSx = this._cutSx;
obj.cutEx = this._cutEx;
obj.cutSy = this._cutSy;
Expand Down Expand Up @@ -714,6 +727,7 @@ proto._highlightPaddingLeft = 0;
proto._highlightPaddingRight = 0;
proto._letterSpacing = 0;
proto._textIndent = 0;
proto._rtl = 0;
proto._cutSx = 0;
proto._cutEx = 0;
proto._cutSy = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/textures/TextTextureRenderer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default class TextTextureRenderer {
this._stage.getOption('defaultFontFace'),
);
this._context.textBaseline = this._settings.textBaseline;
this._context.direction = this._settings.rtl ? "rtl" : "ltr";
};

_load() {
Expand Down Expand Up @@ -306,6 +307,9 @@ export default class TextTextureRenderer {
linePositionX += ((renderInfo.innerWidth - renderInfo.lineWidths[i]) / 2);
}
linePositionX += renderInfo.paddingLeft;
if (this._settings.rtl) {
linePositionX += renderInfo.lineWidths[i];
}

drawLines.push({text: renderInfo.lines[i], x: linePositionX, y: linePositionY, w: renderInfo.lineWidths[i]});
}
Expand Down

0 comments on commit 0d399b2

Please sign in to comment.