From 33bafbd427d5e80db059886c4b116e4ac97d3cf8 Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Fri, 18 Aug 2023 21:05:18 +0800 Subject: [PATCH] fix: reduce underline distance #247 --- src/editor/core/draw/Draw.ts | 9 +++++++-- src/editor/core/draw/richtext/Underline.ts | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/editor/core/draw/Draw.ts b/src/editor/core/draw/Draw.ts index 5417244..293e406 100644 --- a/src/editor/core/draw/Draw.ts +++ b/src/editor/core/draw/Draw.ts @@ -1443,7 +1443,8 @@ export class Draw { const { rowList, pageNo, elementList, positionList, startIndex, zone } = payload const isPrintMode = this.mode === EditorMode.PRINT - const { scale, tdPadding } = this.options + const { scale, tdPadding, defaultBasicRowMarginHeight, defaultRowMargin } = + this.options const { isCrossRowCol, tableId } = this.range.getRange() let index = startIndex for (let i = 0; i < rowList.length; i++) { @@ -1540,10 +1541,14 @@ export class Draw { } // 下划线记录 if (element.underline) { + const rowMargin = + defaultBasicRowMarginHeight * + (element.rowMargin || defaultRowMargin) * + scale this.underline.recordFillInfo( ctx, x, - y + curRow.height, + y + curRow.height - rowMargin, metrics.width, 0, element.color diff --git a/src/editor/core/draw/richtext/Underline.ts b/src/editor/core/draw/richtext/Underline.ts index 19dfb04..33d1ac3 100644 --- a/src/editor/core/draw/richtext/Underline.ts +++ b/src/editor/core/draw/richtext/Underline.ts @@ -16,7 +16,7 @@ export class Underline extends AbstractRichText { const { x, y, width } = this.fillRect ctx.save() ctx.strokeStyle = this.fillColor || underlineColor - const adjustY = y + 0.5 // 从1处渲染,避免线宽度等于3 + const adjustY = Math.floor(y + 2 * ctx.lineWidth) + 0.5 // +0.5从1处渲染,避免线宽度等于3 ctx.beginPath() ctx.moveTo(x, adjustY) ctx.lineTo(x + width, adjustY)