问题
I am using fabric.js library. I want to vertically align text to ceneter of textbox area. Please see image.
In image default cursor is align to top but i want it to center. Is there any property for text as valign
like textalign
?
Tried originY
but no luck.
回答1:
fabric.js 3.5.1 works with originY: 'center'
see FabricJS: Vertical Align text center
.... but the bounding-box has no "minimum height" setting
and paddingX / paddingY are not supported by fabric
to solve this in fabric,
you must override the render function, as shown in
Draw border on Fabric Textbox when it's not selected
but it should be easier to use html elements,
and put them over your canvas, as shown in
How to put an html element over a fabric.js element
来源:https://stackoverflow.com/questions/49110454/fabric-js-text-vertical-align-to-center