mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-20 11:21:51 +00:00
Make sure text objects have dimensions before they're added to canvas. Closes #158.
This commit is contained in:
parent
0371d7ba7c
commit
82ba3169f7
4 changed files with 30 additions and 3 deletions
14
dist/all.js
vendored
14
dist/all.js
vendored
|
|
@ -12446,10 +12446,22 @@ fabric.Image.filters.GradientTransparency.fromObject = function(object) {
|
|||
this.text = text;
|
||||
this.setOptions(options);
|
||||
this.theta = this.angle * Math.PI / 180;
|
||||
this.width = this.getWidth();
|
||||
this._initDimensions();
|
||||
this.setCoords();
|
||||
},
|
||||
|
||||
_initDimensions: function() {
|
||||
|
||||
// render on offscreen canvas, so that object would get dimensions
|
||||
var canvasEl = fabric.document.createElement('canvas');
|
||||
|
||||
if (!canvasEl.getContext && typeof G_vmlCanvasManager != 'undefined') {
|
||||
G_vmlCanvasManager.initElement(canvasEl);
|
||||
}
|
||||
|
||||
this._render(canvasEl.getContext('2d'));
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates `stateProperties` list on an instance, and adds `fabric.Text` -specific ones to it
|
||||
* (such as "fontFamily", "fontWeight", etc.)
|
||||
|
|
|
|||
2
dist/all.min.js
vendored
2
dist/all.min.js
vendored
File diff suppressed because one or more lines are too long
BIN
dist/all.min.js.gz
vendored
BIN
dist/all.min.js.gz
vendored
Binary file not shown.
|
|
@ -121,10 +121,25 @@
|
|||
this.text = text;
|
||||
this.setOptions(options);
|
||||
this.theta = this.angle * Math.PI / 180;
|
||||
this.width = this.getWidth();
|
||||
this._initDimensions();
|
||||
this.setCoords();
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders text object on offscreen canvas, so that it would get dimensions
|
||||
* @private
|
||||
* @method _initDimensions
|
||||
*/
|
||||
_initDimensions: function() {
|
||||
var canvasEl = fabric.document.createElement('canvas');
|
||||
|
||||
if (!canvasEl.getContext && typeof G_vmlCanvasManager != 'undefined') {
|
||||
G_vmlCanvasManager.initElement(canvasEl);
|
||||
}
|
||||
|
||||
this._render(canvasEl.getContext('2d'));
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates `stateProperties` list on an instance, and adds `fabric.Text` -specific ones to it
|
||||
* (such as "fontFamily", "fontWeight", etc.)
|
||||
|
|
|
|||
Loading…
Reference in a new issue