Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

enter code here

like image 958
Dmytro Avatar asked Nov 07 '25 16:11

Dmytro


1 Answers

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).

like image 84
Conan Avatar answered Nov 09 '25 08:11

Conan