diff --git a/src/shapes/itext.class.js b/src/shapes/itext.class.js index f6818e0c82c..e9716ea20f1 100644 --- a/src/shapes/itext.class.js +++ b/src/shapes/itext.class.js @@ -306,6 +306,21 @@ fabric.util.object.extend(this._getStyleDeclaration(loc.lineIndex, loc.charIndex), styles); }, + /** + * Initialize text dimensions. Render all text on given context + * or on a offscreen canvas to get the text width with measureText. + * Updates this.width and this.height with the proper values. + * Does not return dimensions. + * @param {CanvasRenderingContext2D} [ctx] Context to render on + * @private + */ + _initDimensions: function(ctx) { + if (!ctx) { + this.clearContextTop(); + } + this.callSuper('_initDimensions', ctx); + }, + /** * @private * @param {CanvasRenderingContext2D} ctx Context to render on diff --git a/src/shapes/object.class.js b/src/shapes/object.class.js index c0c436f44e5..7092c3cc7f3 100644 --- a/src/shapes/object.class.js +++ b/src/shapes/object.class.js @@ -773,7 +773,7 @@ * @type Boolean * @default */ - statefullCache: false, + statefullCache: true, /** * When `true`, cache does not get updated during scaling. The picture will get blocky if scaled @@ -851,10 +851,10 @@ dim = this._getNonTransformedDimensions(), retina = this.canvas && this.canvas._isRetinaScaling() ? fabric.devicePixelRatio : 1, zoomX = objectScale.scaleX * zoom * retina, - zoomY = objectScale.scaleY * zoom * retina; - if (zoomX !== this.zoomX || zoomY !== this.zoomY) { - var width = dim.x * zoomX, - height = dim.y * zoomY; + zoomY = objectScale.scaleY * zoom * retina, + width = dim.x * zoomX, + height = dim.y * zoomY; + if (width !== this.cacheWidth || height !== this.cacheHeight) { this._cacheCanvas.width = width; this._cacheCanvas.height = height; this._cacheContext.translate(width / 2, height / 2);