Template for issues

by Arthur Lutkevichus

HTML

<script src="https://rawgithub.com/kangax/fabric.js/master/dist/fabric.js"></script>
<canvas id="c" width="600" height="600"></canvas>

CSS

canvas {
    border: 1px solid #999;
}

JavaScript

/**
 * fabric.js template for bug reports
 *
 * Please update the name of the jsfiddle (see Fiddle Options).
 * This templates uses latest dev verison of fabric.js (https://rawgithub.com/kangax/fabric.js/master/dist/fabric.js).
 */

// initialize fabric canvas and assign to global windows object for debug
var canvas = window._canvas = new fabric.Canvas('c');

// ADD YOUR CODE HERE
var canvas = window._canvas = new fabric.Canvas('c');
var t1 = new fabric.Textbox('My Text', {
    width: 200,
    top: 5,
    left: 5,
    fontSize: 16,
    textAlign: 'center'
});
var someText = 'My text is longer, but I do not want the box to grow, or the text to wrap. I only want the text to fit the available size';
var textSize = new fabric.Text(someText,{
				    fontSize: 16
				});
        console.log(textSize.width);
var textBoxWidth = textSize.width;

if (canvas.width < textBoxWidth){
textBoxWidth = canvas.width - 10;
}
var t2 = new fabric.Textbox(someText, {
    width: textBoxWidth,
    height: 200,
    top: 250,
    left: 5,
    fontSize: 16,
    textAlign: 'center'
});



canvas.add(t1);
canvas.add(t2);