fixed IText's cursor and text selection not ignoring charSpacing at the end of line (#5008) (#5009)

This commit is contained in:
Nick Zaitsev 2018-05-30 03:53:17 -03:00 committed by Andrea Bogazzi
parent b1c25a4f56
commit b77957f3ec

View file

@ -341,18 +341,19 @@
return this.cursorOffsetCache;
}
var lineLeftOffset,
lineIndex = 0,
charIndex = 0,
lineIndex,
charIndex,
topOffset = 0,
leftOffset = 0,
boundaries,
cursorPosition = this.get2DCursorLocation(position);
for (var i = 0; i < cursorPosition.lineIndex; i++) {
charIndex = cursorPosition.charIndex;
lineIndex = cursorPosition.lineIndex;
for (var i = 0; i < lineIndex; i++) {
topOffset += this.getHeightOfLine(i);
}
lineLeftOffset = this._getLineLeftOffset(cursorPosition.lineIndex);
var bound = this.__charBounds[cursorPosition.lineIndex][cursorPosition.charIndex];
lineLeftOffset = this._getLineLeftOffset(lineIndex);
var bound = this.__charBounds[lineIndex][charIndex];
bound && (leftOffset = bound.left);
if (this.charSpacing !== 0 && charIndex === this._textLines[lineIndex].length) {
leftOffset -= this._getWidthOfCharSpacing();
@ -429,7 +430,9 @@
boxEnd = this.__charBounds[endLine][endChar].left;
}
else {
boxEnd = this.__charBounds[endLine][endChar - 1].left + this.__charBounds[endLine][endChar - 1].width;
var charSpacing = this._getWidthOfCharSpacing();
boxEnd = this.__charBounds[endLine][endChar - 1].left
+ this.__charBounds[endLine][endChar - 1].width - charSpacing;
}
}
realLineHeight = lineHeight;