我的项目使用fabric js,我想知道是否可以允许调整文本字段的大小,但不缩放其中的内容(字体)。
参见此处的示例:
http://fabricjs.com/test/misc/itext.html
上面的示例似乎缩放了iText对象中的文本。但我想调整方框本身的大小,所以当我把文本框调大时,里面的文本应该放在一行。
我尝试使用以下选项:
lockScalingY: true,
lockScalingX: false,
lockUniScaling :false
您想要的是以"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>