fix: 合并文本框宽度用 rect.w 而非 parentW
合并节点的 parentW 继承自第一个子节点(如 strong 的窄宽度), 导致文本框太窄。改为用合并后的 rect.w。
This commit is contained in:
+2
-2
@@ -591,7 +591,7 @@ function convert(input) {
|
|||||||
opts.fontSize = pt;
|
opts.fontSize = pt;
|
||||||
opts.fontFace = (st.fontFamily || 'Arial').split(',')[0].replace(/['"]/g,'').trim();
|
opts.fontFace = (st.fontFamily || 'Arial').split(',')[0].replace(/['"]/g,'').trim();
|
||||||
opts.color = rgbaToHex(st.color) || '000000';
|
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.fontStyle === 'italic') opts.italic = true;
|
||||||
if (st.textAlign && st.textAlign !== 'start') opts.align = st.textAlign;
|
if (st.textAlign && st.textAlign !== 'start') opts.align = st.textAlign;
|
||||||
// 文字装饰
|
// 文字装饰
|
||||||
@@ -618,7 +618,7 @@ function convert(input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 宽度:parentW 超过 contentW 的 80% 时视为顶层,用 contentW;否则用 parentW
|
// 宽度: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 * 0.8) textW = contentW;
|
||||||
if (textW > contentW) textW = contentW;
|
if (textW > contentW) textW = contentW;
|
||||||
if (textW < 108) textW = 108; // 最小 1.5in = 108px
|
if (textW < 108) textW = 108; // 最小 1.5in = 108px
|
||||||
|
|||||||
Reference in New Issue
Block a user