From f317b962629e897b5ea3e54231be5f8fd054b86e Mon Sep 17 00:00:00 2001 From: tisilent Date: Fri, 11 Aug 2023 17:58:29 +0800 Subject: [PATCH 1/2] Fix canvas underline is cut off. --- src/browser/renderer/shared/TextureAtlas.ts | 24 ++++++++------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/browser/renderer/shared/TextureAtlas.ts b/src/browser/renderer/shared/TextureAtlas.ts index e77e595d..f0f5d864 100644 --- a/src/browser/renderer/shared/TextureAtlas.ts +++ b/src/browser/renderer/shared/TextureAtlas.ts @@ -532,10 +532,11 @@ export class TextureAtlas implements ITextureAtlas { // Underline style/stroke this._tmpCtx.beginPath(); const xLeft = padding; - const yTop = Math.ceil(padding + this._config.deviceCharHeight) - yOffset; - const yMid = padding + this._config.deviceCharHeight + lineWidth - yOffset; - const yBot = Math.ceil(padding + this._config.deviceCharHeight + lineWidth * 2) - yOffset; - const ySpace = lineWidth * 2; + const yTop = restrictToCellHeight ? + Math.ceil(padding + this._config.deviceCharHeight) - yOffset - lineWidth * 2 : + Math.ceil(padding + this._config.deviceCharHeight) - yOffset; + const yMid = yTop + lineWidth; + const yBot = yTop + lineWidth * 2; for (let i = 0; i < chWidth; i++) { this._tmpCtx.save(); @@ -544,17 +545,10 @@ export class TextureAtlas implements ITextureAtlas { const xChMid = xChLeft + this._config.deviceCellWidth / 2; switch (this._workAttributeData.extended.underlineStyle) { case UnderlineStyle.DOUBLE: - if (restrictToCellHeight) { - this._tmpCtx.moveTo(xChLeft, yTop - ySpace); - this._tmpCtx.lineTo(xChRight, yTop - ySpace); - this._tmpCtx.moveTo(xChLeft, yTop); - this._tmpCtx.lineTo(xChRight, yTop); - } else { - this._tmpCtx.moveTo(xChLeft, yTop); - this._tmpCtx.lineTo(xChRight, yTop); - this._tmpCtx.moveTo(xChLeft, yBot); - this._tmpCtx.lineTo(xChRight, yBot); - } + this._tmpCtx.moveTo(xChLeft, yTop); + this._tmpCtx.lineTo(xChRight, yTop); + this._tmpCtx.moveTo(xChLeft, yBot); + this._tmpCtx.lineTo(xChRight, yBot); break; case UnderlineStyle.CURLY: // Choose the bezier top and bottom based on the device pixel ratio, the curly line is From 07d187151e1855a7c9d42f6b99bd4909efb9c07a Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 11 Aug 2023 09:50:22 -0700 Subject: [PATCH 2/2] Update src/browser/renderer/shared/TextureAtlas.ts --- src/browser/renderer/shared/TextureAtlas.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/browser/renderer/shared/TextureAtlas.ts b/src/browser/renderer/shared/TextureAtlas.ts index f0f5d864..b73e7009 100644 --- a/src/browser/renderer/shared/TextureAtlas.ts +++ b/src/browser/renderer/shared/TextureAtlas.ts @@ -532,9 +532,7 @@ export class TextureAtlas implements ITextureAtlas { // Underline style/stroke this._tmpCtx.beginPath(); const xLeft = padding; - const yTop = restrictToCellHeight ? - Math.ceil(padding + this._config.deviceCharHeight) - yOffset - lineWidth * 2 : - Math.ceil(padding + this._config.deviceCharHeight) - yOffset; + const yTop = Math.ceil(padding + this._config.deviceCharHeight) - yOffset - (restrictToCellHeight ? lineWidth * 2 : 0); const yMid = yTop + lineWidth; const yBot = yTop + lineWidth * 2;