title: Fabric.js: Get text bounding box width and height
body: <p>I'm using fabric.js.  I would like to get the dimensions of the rectangle (is "bounding box" the correct term?) that exactly contains the text (represented by the red box below).  The default fabric.js box has padding even if I change padding to 0. </p>
  
  <p><a href="https://i.stack.imgur.com/etxBD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/etxBD.png" alt="enter image description here"></a></p>
  
  <p>I tried to get the context from the fabric canvas and then call .measureText() but it didn't give the full information I needed for a bounding box.</p>
  
  <p>EDIT:</p>
  
  <p>It seems there are several components of the IText object: the container, the selection area, and the text itself.  In the image below, the IText box is the light blue line.  The selection area is the light blue fill.  <strong>The red box is what I need</strong>....it's the area that <em>exactly</em> contains the text itself (<em>not even 1 pixel</em> between such a rectangle and the most extreme parts of the text).  The methods getBoundingRectHeight and getBoundingRectWidth (both deprecated and replaced by getBoundingRect I believe) return the height/width of the outer IText container box (light blue line).  </p>
  
  <p><a href="https://i.stack.imgur.com/cuUjS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cuUjS.png" alt="enter image description here"></a></p>
  
  <p>Note: this is an 8 px padded box (the area between the blue line and blue fill).  Even if I make padding 0, the functions still don't give me what I need.</p>