mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-13 16:23:11 +00:00
Merge pull request #2183 from asturur/Fix-patterns-for-text
Fix patterns offset for text
This commit is contained in:
commit
c71a1c2049
2 changed files with 13 additions and 12 deletions
|
|
@ -258,17 +258,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (object.type === 'text' || object.type === 'i-text') {
|
||||
for (prop in coords) {
|
||||
if (prop === 'x1' || prop === 'x2') {
|
||||
coords[prop] -= object.width / 2;
|
||||
}
|
||||
else if (prop === 'y1' || prop === 'y2') {
|
||||
coords[prop] -= object.height / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.type === 'linear') {
|
||||
gradient = ctx.createLinearGradient(
|
||||
coords.x1, coords.y1, coords.x2, coords.y2);
|
||||
|
|
|
|||
|
|
@ -434,7 +434,19 @@
|
|||
* @param {Number} top Top position of text
|
||||
*/
|
||||
_renderChars: function(method, ctx, chars, left, top) {
|
||||
// remove Text word from method var
|
||||
var shortM = method.slice(0, -4);
|
||||
if (this[shortM].toLive) {
|
||||
var offsetX = -this.width / 2 + this[shortM].offsetX || 0,
|
||||
offsetY = -this.height / 2 + this[shortM].offsetY || 0;
|
||||
ctx.save();
|
||||
ctx.translate(offsetX, offsetY);
|
||||
left -= offsetX;
|
||||
top -= offsetY;
|
||||
}
|
||||
console.log(ctx.strokeStyle);
|
||||
ctx[method](chars, left, top);
|
||||
this[shortM].toLive && ctx.restore();
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -540,7 +552,7 @@
|
|||
|
||||
var lineHeights = 0;
|
||||
|
||||
if (!this.shadow.affectStroke) {
|
||||
if (this.shadow && !this.shadow.affectStroke) {
|
||||
this._removeShadow(ctx);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue