I’m using fabric.js version 5.3.0.
Textbox object will wrap text when you add space between words but not wrap when you add text without space.
Please check below fiddle:
https://jsfiddle.net/Niketa_patel/fo5q1bzt/10/
Here is the code:
var canvas = new fabric.Canvas("c");
var str = 'Please type a long word and watch me break!';
var textbox = new fabric.Textbox(str, {
width: 200,
});
canvas.add(textbox);
function setcharspacing(){
textbox.set('charSpacing',100);
canvas.renderAll();
}
I have also tried custom function to wrap the text but it’s not working with charSpacing.
Here is the referral link which I have tried:
https://jjwilly.com/blog/fabricjs-2-0-breakwords
Expectation:
should wrap text proper when you add text without space with charSpacing(charSpacing value between -100 to 100)
It would be really appreciated if anyone can help me.
Thank you !