Skip to content

Commit 0d399b2

Browse files
committed
Merge branch 'dev' into release/2.13.0
2 parents 9a35ac6 + c3780e5 commit 0d399b2

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

scripts/src-to-dist.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ console.log("Copying all JavaScript source code to ./dist...");
1414
shell.find('./src/')
1515
.filter(file => {
1616
const ext = path.extname(file);
17-
return ['.js', '.mjs', '.d.mts', '.d.ts'].includes(ext) && !file.includes('.test.');
17+
return ['.js', '.mjs', '.mts', '.ts'].includes(ext) && !file.includes('.test.');
1818
})
1919
.forEach(file => {
2020
const distFile = path.join('./dist', file);

src/textures/TextTexture.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,17 @@ export default class TextTexture extends Texture {
466466
return this._textIndent;
467467
}
468468

469+
set rtl(v) {
470+
if (this._rtl !== v) {
471+
this._rtl = v;
472+
this._changed();
473+
}
474+
}
475+
476+
get rtl() {
477+
return this._rtl;
478+
}
479+
469480
get precision() {
470481
return super.precision;
471482
}
@@ -620,6 +631,7 @@ export default class TextTexture extends Texture {
620631
if (this.highlightPaddingRight !== 0) nonDefaults["highlightPaddingRight"] = this.highlightPaddingRight;
621632
if (this.letterSpacing !== 0) nonDefaults["letterSpacing"] = this.letterSpacing;
622633
if (this.textIndent !== 0) nonDefaults["textIndent"] = this.textIndent;
634+
if (this.rtl !== 0) nonDefaults["rtl"] = this.rtl;
623635

624636
if (this.cutSx) nonDefaults["cutSx"] = this.cutSx;
625637
if (this.cutEx) nonDefaults["cutEx"] = this.cutEx;
@@ -667,6 +679,7 @@ export default class TextTexture extends Texture {
667679
obj.highlightPaddingRight = this._highlightPaddingRight;
668680
obj.letterSpacing = this._letterSpacing;
669681
obj.textIndent = this._textIndent;
682+
obj.rtl = this._rtl;
670683
obj.cutSx = this._cutSx;
671684
obj.cutEx = this._cutEx;
672685
obj.cutSy = this._cutSy;
@@ -714,6 +727,7 @@ proto._highlightPaddingLeft = 0;
714727
proto._highlightPaddingRight = 0;
715728
proto._letterSpacing = 0;
716729
proto._textIndent = 0;
730+
proto._rtl = 0;
717731
proto._cutSx = 0;
718732
proto._cutEx = 0;
719733
proto._cutSy = 0;

src/textures/TextTextureRenderer.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export default class TextTextureRenderer {
4343
this._stage.getOption('defaultFontFace'),
4444
);
4545
this._context.textBaseline = this._settings.textBaseline;
46+
this._context.direction = this._settings.rtl ? "rtl" : "ltr";
4647
};
4748

4849
_load() {
@@ -306,6 +307,9 @@ export default class TextTextureRenderer {
306307
linePositionX += ((renderInfo.innerWidth - renderInfo.lineWidths[i]) / 2);
307308
}
308309
linePositionX += renderInfo.paddingLeft;
310+
if (this._settings.rtl) {
311+
linePositionX += renderInfo.lineWidths[i];
312+
}
309313

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

0 commit comments

Comments
 (0)