In this article, we are going to see how to lock horizontal scaling of a text canvas using FabricJS. The canvas means text written is movable, rotatable, resizable and can be stretched. But in this article, we will lock horizontal scaling so that it cannot be scaled horizontally and the length of the Text object cannot be changed. Further, the text itself cannot be edited like a textbox.
fabric.Text(text, lockScalingX: boolean);
Parameters: This function accept two parameters as mentioned above and described below:
- text: It specifies the text to be written.
- lockScalingX: It specifies whether to enable or disable the horizontal scaling lock, disabled by default.
Example: We can use FabricJS to lock horizontal scaling of a canvas-like text as given below.