Skip to content

Commit bd2642e

Browse files
committed
fix: use outerWidth for bounding box
1 parent 7b5a564 commit bd2642e

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/graphic/Text.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,8 @@ class ZRText extends Displayable<TextProps> implements GroupLike {
484484
const needDrawBg = needDrawBackground(style);
485485
const bgColorDrawn = !!(style.backgroundColor);
486486

487-
// outerWidth is the real text width containing padding.
488487
const outerHeight = contentBlock.outerHeight;
488+
const outerWidth = contentBlock.outerWidth;
489489
const contentWidth = contentBlock.contentWidth;
490490

491491
const textLines = contentBlock.lines;
@@ -503,10 +503,9 @@ class ZRText extends Displayable<TextProps> implements GroupLike {
503503

504504
if (needDrawBg || textPadding) {
505505
// Consider performance, do not call getTextWidth util necessary.
506-
const boxX = adjustTextX(baseX, contentWidth, textAlign);
506+
const boxX = adjustTextX(baseX, outerWidth, textAlign);
507507
const boxY = adjustTextY(baseY, outerHeight, verticalAlign);
508-
509-
needDrawBg && this._renderBackground(style, style, boxX, boxY, contentWidth, outerHeight);
508+
needDrawBg && this._renderBackground(style, style, boxX, boxY, outerWidth, outerHeight);
510509
}
511510

512511
// `textBaseline` is set as 'middle'.
@@ -605,7 +604,7 @@ class ZRText extends Displayable<TextProps> implements GroupLike {
605604
* Otherwise, there will be extra space in the
606605
* bounding rect calculated.
607606
*/
608-
innerWidth,
607+
contentWidth,
609608
calculatedLineHeight
610609
));
611610
}

src/graphic/helper/parseText.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ export function parsePlainText(
263263
outerHeight: outerHeight,
264264
lineHeight: lineHeight,
265265
calculatedLineHeight: calculatedLineHeight,
266-
contentWidth: outerWidth,
266+
contentWidth: contentWidth,
267267
contentHeight: contentHeight,
268268
width: width
269269
};

0 commit comments

Comments
 (0)