From 8f507256ef96f72968f76c08d6d48353979d1a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=BF=9B?= Date: Fri, 24 Jul 2026 17:25:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=88=E5=B9=B6=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E6=A1=86=E5=AE=BD=E5=BA=A6=E7=94=A8=20rect.w=20=E8=80=8C?= =?UTF-8?q?=E9=9D=9E=20parentW?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 合并节点的 parentW 继承自第一个子节点(如 strong 的窄宽度), 导致文本框太窄。改为用合并后的 rect.w。 --- convert-w2p.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/convert-w2p.js b/convert-w2p.js index a4af2a6..0db45dd 100644 --- a/convert-w2p.js +++ b/convert-w2p.js @@ -591,7 +591,7 @@ function convert(input) { opts.fontSize = pt; opts.fontFace = (st.fontFamily || 'Arial').split(',')[0].replace(/['"]/g,'').trim(); opts.color = rgbaToHex(st.color) || '000000'; - if (parseInt(st.fontWeight) >= 700) opts.bold = true; + if (parseInt(st.fontWeight) >= 700 && !n._merged) opts.bold = true; if (st.fontStyle === 'italic') opts.italic = true; if (st.textAlign && st.textAlign !== 'start') opts.align = st.textAlign; // 文字装饰 @@ -618,7 +618,7 @@ function convert(input) { } // 宽度:parentW 超过 contentW 的 80% 时视为顶层,用 contentW;否则用 parentW - var textW = n.parentW || r.w; + var textW = n._merged ? r.w : (n.parentW || r.w); // 合并节点用 rect.w if (textW > contentW * 0.8) textW = contentW; if (textW > contentW) textW = contentW; if (textW < 108) textW = 108; // 最小 1.5in = 108px