How to get width and height of bounding rectangle of font character?

1.7k views Asked by At

I am curious is it possible to get bounding rectangle width and height of font characters with javascript?

enter code here

1

There are 1 answers

1
Conan On

depending on your exact implementation, you might find this useful: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/measureText

The CanvasRenderingContext2D.measureText() method returns a TextMetrics object that contains information about the measured text (such as its width for example).