Update itext.class.js

This commit is contained in:
Andrea Bogazzi 2016-09-05 20:01:32 +02:00 committed by GitHub
parent c5175d66e9
commit 5dbbcdb682

View file

@ -490,7 +490,7 @@
}
boundaries = {
top: topOffset,
left: leftOffset,
left: leftOffset > 0 ? leftOffset : 0,
lineLeft: lineLeftOffset
};
this.cursorOffsetCache = boundaries;
@ -574,7 +574,7 @@
ctx.fillRect(
boundaries.left + lineOffset,
boundaries.top + boundaries.topOffset,
boxWidth,
boxWidth > 0 ? boxWidth : 0,
lineHeight);
boundaries.topOffset += realLineHeight;
@ -653,7 +653,7 @@
_renderChar: function(method, ctx, lineIndex, i, _char, left, top, lineHeight) {
var charWidth, charHeight, shouldFill, shouldStroke,
decl = this._getStyleDeclaration(lineIndex, i),
offset, textDecoration, chars;
offset, textDecoration, chars, additionalSpace, _charWidth;
if (decl) {
charHeight = this._getHeightOfChar(ctx, _char, lineIndex, i);
@ -677,13 +677,15 @@
this._removeShadow(ctx);
}
if (this.charSpacing !== 0) {
additionalSpace = this._getWidthOfCharSpacing();
chars = _char.split('');
charWidth = 0;
for (var j = 0, len = chars.length, char; j < len; j++) {
char = chars[j];
shouldFill && ctx.fillText(char, left + charWidth, top);
shouldStroke && ctx.strokeText(char, left + charWidth, top);
charWidth += ctx.measureText(char).width + this._getWidthOfCharSpacing();
_charWidth = ctx.measureText(char).width + additionalSpace;
charWidth += _charWidth > 0 ? _charWidth : 0;
}
}
else {
@ -992,7 +994,7 @@
width += this._getWidthOfCharSpacing();
}
ctx.restore();
return width < 0 ? 0 : width;
return width > 0 ? width : 0
},
/**
@ -1034,7 +1036,7 @@
width -= this._getWidthOfCharSpacing();
}
this._isMeasuring = false;
return width;
return width > 0 ? width : 0;
},
/**