Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/editor/core/draw/Draw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,19 @@ export class Draw {
rowFlex: elementList[i]?.rowFlex || elementList[i + 1]?.rowFlex,
isPageBreak: element.type === ElementType.PAGE_BREAK
}
// 有些字符的上升高度可能是负数,比如下划线
// 所以行高大于等于上身高度时,赋予一个基础的上升高度避免行塌陷
// 比如整行都是空格,行上升高度为rowMargin
// 比如整行都是下划线,行上升高度小于rowMargin
if (row.ascent <= rowMargin) {
const boundingBoxAscent =
this.textParticle.getBasisWordBoundingBoxAscent(
ctx,
element.font!
) * scale
row.ascent = rowMargin + boundingBoxAscent
row.height = rowMargin + boundingBoxAscent
}
// 控件缩进
if (
rowElement.controlComponent !== ControlComponent.PREFIX &&
Expand Down Expand Up @@ -1972,17 +1985,6 @@ export class Draw {
}
curRow.width = availableWidth
}
// 行距离顶部偏移量等于行高时 => 行增加默认标准元素偏移量
// 如整行都是空格测量偏移量为0,导致行塌陷
if (curRow.ascent === rowMargin) {
const boundingBoxDescent =
this.textParticle.getBasisWordBoundingBoxAscent(
ctx,
element.font!
) * scale
curRow.ascent += boundingBoxDescent
curRow.height += boundingBoxDescent
}
}
// 重新计算坐标、页码、下一行首行元素环绕交叉
if (isWrap) {
Expand Down