diff --git a/CHANGELOG.md b/CHANGELOG.md index edd87f30..fc9543a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v2.13.0 +*11 apr 2024* + +- Fixed an issue causing not including TypeScript types in the build. (#527) +- Enhanced handling of bidirectional text in TextTexture by setting canvas context direction to correct display of text blocks in RTL configurations. + ## v2.12.1 *07 feb 2024* diff --git a/package-lock.json b/package-lock.json index 03a7a74f..9e727f15 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@lightningjs/core", - "version": "2.12.1", + "version": "2.13.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@lightningjs/core", - "version": "2.12.1", + "version": "2.13.0", "license": "Apache-2.0", "devDependencies": { "@babel/core": "^7.8.3", diff --git a/package.json b/package.json index c6ea5e38..65c6e548 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "Metrological, Bas van Meurs ", "name": "@lightningjs/core", - "version": "2.12.1", + "version": "2.13.0", "license": "Apache-2.0", "type": "module", "types": "dist/src/index.d.ts", diff --git a/scripts/src-to-dist.cjs b/scripts/src-to-dist.cjs index c6770a32..87d030fd 100644 --- a/scripts/src-to-dist.cjs +++ b/scripts/src-to-dist.cjs @@ -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); diff --git a/src/textures/TextTexture.mjs b/src/textures/TextTexture.mjs index 6d0d592c..547dfa78 100644 --- a/src/textures/TextTexture.mjs +++ b/src/textures/TextTexture.mjs @@ -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; } @@ -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; @@ -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; @@ -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; diff --git a/src/textures/TextTextureRenderer.mjs b/src/textures/TextTextureRenderer.mjs index 92d6a7d6..c2201619 100644 --- a/src/textures/TextTextureRenderer.mjs +++ b/src/textures/TextTextureRenderer.mjs @@ -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() { @@ -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]}); }