diff --git a/src/graphic/Text.ts b/src/graphic/Text.ts index d7fd9f27e..6947bda39 100644 --- a/src/graphic/Text.ts +++ b/src/graphic/Text.ts @@ -675,6 +675,14 @@ class ZRText extends Displayable implements GroupLike { leftIndex++; } + while (leftIndex < tokenCount + && (token = tokens[leftIndex], !token.align || token.align === 'right')) { + remainedWidth -= token.width; + lineXLeft += token.width; + this._placeToken(token, style, lineHeight, lineTop, lineXLeft, 'right', bgColorDrawn); + leftIndex++; + } + while ( rightIndex >= 0 && (token = tokens[rightIndex], token.align === 'right') @@ -684,7 +692,14 @@ class ZRText extends Displayable implements GroupLike { lineXRight -= token.width; rightIndex--; } - + while (rightIndex >= 0 + && (token = tokens[rightIndex], token.align === 'left')) { + lineXRight -= token.width; + this._placeToken(token, style, lineHeight, lineTop, lineXRight, 'left', bgColorDrawn); + remainedWidth -= token.width; + rightIndex--; + } + // The other tokens are placed as textAlign 'center' if there is enough space. lineXLeft += (contentWidth - (lineXLeft - xLeft) - (xRight - lineXRight) - remainedWidth) / 2; while (leftIndex <= rightIndex) {