how to measure the font metrics in javascript? Is there any API available for text metrics like GetCellDescent in C#?
<pre><code>function calculateSpanHeight(testLine,font){
          var spanElement = $(document.createElement("span")).css("white-space","pre");
          spanElement[0].id = "tempSpan";
          var spanElement = $(spanElement).html(testLine);
          $(spanElement).appendTo("body");
          $(spanElement).css("font",context.font);
          var testWidth = $("#tempSpan").width();
          var height = $("#tempSpan").height();

          var block = $('&lt;div style="display: inline-block; width: 1px; height: 0px;"&gt;&lt;/div&gt;');

          var div = $('&lt;div&gt;&lt;/div&gt;');
          div.append(spanElement, block);

          var body = $('body');
          body.append(div);

          var result = {};

          block.css({ verticalAlign: 'baseline' });
          result.ascent = block.offset().top - spanElement.offset().top;

          block.css({ verticalAlign: 'bottom' });
          result.height = block.offset().top - spanElement.offset().top;

          result.descent = result.height - result.ascent;
          $(div).remove();
          return {"testWidth" : testWidth, "height" : height, "spanElement" : spanElement, "ascent" : result.ascent, "descent" : result.descent};
      }
</code></pre>

<p>I have used this following code. It is working fine for getting the text width and height values exactly. But i need the text ascent and descent values exactly that is in float value. Please help me and Thanks in advance.</p>