TheDeveloper
TheDeveloper

Reputation: 940

Fabric js - IText object allow re size but not scale

I am using fabric js for my project, i wondered if its possible to allow the resizing of a text field but not scale the content (font) within.

see example here:

http://fabricjs.com/test/misc/itext.html

The examples above seem to scale the text within the iText object. But I want to resize the box itself, so when i make the text box bigger the text inside should go on to one line.

I tried using the following options:

 lockScalingY: true,
 lockScalingX: false,
 lockUniScaling :false

Upvotes: 1

Views: 3512

Answers (1)

AndreaBogazzi
AndreaBogazzi

Reputation: 14741

What are you asking for has been developed under the name "fabric.Textbox".

 var canvas = new fabric.Canvas('canvas');
canvas.add(new fabric.Textbox('hello, im a resizable textbox, please feel free to resize me at will untill you meet size of the longest word', {width:250}))
<script src="http://fabricjs.com/lib/fabric.js"></script>
<canvas id='canvas' width="400" height="400" style="border:#000 1px solid;"></canvas>

Upvotes: 2

Related Questions