I am currently using fabric.js version 5.3.0.
The Textbox object in fabric.js will wrap text when you add space between words, but it won't wrap when you add text without any spaces.
Please take a look at the following fiddle: https://jsfiddle.net/Niketa_patel/fo5q1bzt/10/
Below is the code snippet:
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 attempted to create a custom function to wrap the text, but it does not work with charSpacing enabled.
Here is the link I referred to while trying to solve this issue:
Expectation:
The text should wrap correctly even when text is added without spaces, while also enabling charSpacing (with values ranging from -100 to 100).
Any assistance on this matter would be highly appreciated.
Thank you!