Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix text coordinates on init #3745

Merged
merged 3 commits into from
Feb 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/shapes/text.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@
this.callSuper('initialize', options);
this.__skipDimension = false;
this._initDimensions();
this.setCoords();
this.setupState({ propertySet: '_dimensionAffectingProps' });
},

Expand Down
21 changes: 19 additions & 2 deletions test/unit/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

QUnit.module('fabric.Text');

function createTextObject() {
return new fabric.Text('x');
function createTextObject(text) {
return new fabric.Text(text || 'x');
}

var CHAR_WIDTH = 20;
Expand Down Expand Up @@ -141,6 +141,23 @@
equal(text.get('fontFamily'), 'blah');
});

test('get bounding rect after init', function() {
var string = 'Some long text, the quick brown fox jumps over the lazy dog etc... blah blah blah';
var text = new fabric.Text(string, {
left: 30,
top: 30,
fill: '#ffffff',
fontSize: 24,
fontWeight: 'normal',
fontFamily: 'Arial',
originY: 'bottom'
});
var br = text.getBoundingRect();
text.setCoords();
var br2 = text.getBoundingRect();
deepEqual(br, br2, 'text bounding box is the same before and after calling setCoords');
});

test('setShadow', function(){
var text = createTextObject();
ok(typeof text.setShadow == 'function');
Expand Down