How to lock vertical scaling of a text canvas using Fabric.js ?
In this article, we are going to see how to lock vertical 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 vertical scaling so that it cannot be scaled vertically and the height of the Text object cannot be changed. Further, the text itself cannot be edited like a textbox.
fabric.Text(text, lockScalingY: boolean);
Parameters: This function accepts two parameters as mentioned above and described below:
- text: It specifies the text to be written.
- lockScalingY: It specifies whether to enable or disable the vertical scaling lock, disabled by default.
Program: We can use FabricJS to lock vertical scaling of a canvas-like text as given below.