From 2861a4dd392e9a451c08d84b1dc47755eb925ad9 Mon Sep 17 00:00:00 2001 From: tisilent Date: Wed, 8 Nov 2023 17:58:38 +0800 Subject: [PATCH] Draw dashed lines through ratios --- src/browser/renderer/shared/TextureAtlas.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/browser/renderer/shared/TextureAtlas.ts b/src/browser/renderer/shared/TextureAtlas.ts index d7f65d0034..f3f67b8b21 100644 --- a/src/browser/renderer/shared/TextureAtlas.ts +++ b/src/browser/renderer/shared/TextureAtlas.ts @@ -613,7 +613,14 @@ export class TextureAtlas implements ITextureAtlas { nextOffset = computeNextVariantOffset(xChRight - xChLeft, lineWidth, nextOffset); break; case UnderlineStyle.DASHED: - this._tmpCtx.setLineDash([this._config.devicePixelRatio * 4, this._config.devicePixelRatio * 3]); + const lineRatio = 0.6; + const gapRatio = 0.3; + // End line ratio is approximately equal to 0.1 + const xChWidth = xChRight - xChLeft; + const line = Math.floor(lineRatio * xChWidth); + const gap = Math.floor(gapRatio * xChWidth); + const end = xChWidth - line - gap; + this._tmpCtx.setLineDash([line, gap, end]); this._tmpCtx.moveTo(xChLeft, yTop); this._tmpCtx.lineTo(xChRight, yTop); break;