fix: reduce underline distance #247

pr675
Hufe921 3 years ago
parent fef6ddf7a8
commit 33bafbd427

@ -1443,7 +1443,8 @@ export class Draw {
const { rowList, pageNo, elementList, positionList, startIndex, zone } = const { rowList, pageNo, elementList, positionList, startIndex, zone } =
payload payload
const isPrintMode = this.mode === EditorMode.PRINT const isPrintMode = this.mode === EditorMode.PRINT
const { scale, tdPadding } = this.options const { scale, tdPadding, defaultBasicRowMarginHeight, defaultRowMargin } =
this.options
const { isCrossRowCol, tableId } = this.range.getRange() const { isCrossRowCol, tableId } = this.range.getRange()
let index = startIndex let index = startIndex
for (let i = 0; i < rowList.length; i++) { for (let i = 0; i < rowList.length; i++) {
@ -1540,10 +1541,14 @@ export class Draw {
} }
// 下划线记录 // 下划线记录
if (element.underline) { if (element.underline) {
const rowMargin =
defaultBasicRowMarginHeight *
(element.rowMargin || defaultRowMargin) *
scale
this.underline.recordFillInfo( this.underline.recordFillInfo(
ctx, ctx,
x, x,
y + curRow.height, y + curRow.height - rowMargin,
metrics.width, metrics.width,
0, 0,
element.color element.color

@ -16,7 +16,7 @@ export class Underline extends AbstractRichText {
const { x, y, width } = this.fillRect const { x, y, width } = this.fillRect
ctx.save() ctx.save()
ctx.strokeStyle = this.fillColor || underlineColor 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.beginPath()
ctx.moveTo(x, adjustY) ctx.moveTo(x, adjustY)
ctx.lineTo(x + width, adjustY) ctx.lineTo(x + width, adjustY)

Loading…
Cancel
Save