From ed860ddd92a3a7912a51f0dc30ac462ecfb51a5e Mon Sep 17 00:00:00 2001 From: piplup <1370189854@qq.com> Date: Mon, 24 Oct 2022 11:41:07 +0800 Subject: [PATCH] =?UTF-8?q?fix=20bug:=20=E4=BF=AE=E5=A4=8DinlineText?= =?UTF-8?q?=E5=9C=A8=E7=89=B9=E5=AE=9A=E6=83=85=E5=86=B5=E4=B8=8B=E4=BC=9A?= =?UTF-8?q?=E5=8D=A1=E5=B4=A9=E5=BC=80=E5=8F=91=E8=80=85=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/painter/lib/pen.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/components/painter/lib/pen.js b/components/painter/lib/pen.js index d0f099b..444ee4a 100644 --- a/components/painter/lib/pen.js +++ b/components/painter/lib/pen.js @@ -615,6 +615,20 @@ export default class Painter { // 取出文字 let text = subView.text.substr(start, alreadyCount - start); + if (text === "") { + // 重置数据 + start = alreadyCount; + leftWidth -= currentUsedWidth; + x += currentUsedWidth; + // 如果剩余宽度 小于等于0 或者小于一个字的平均宽度,换行 + if (leftWidth <= 0 || leftWidth < preWidth) { + leftWidth = width; + x = staticX; + lineIndex++; + } + continue + } + const y = -(height / 2) + subView.css.fontSize.toPx() + lineIndex * lineHeight; // 设置文字样式