I know I can use context.measureText to get the width of some text if it would now be rendered on the canvas. Is there a way to do the same but get the text's height?
just a thought to myself - maybe I can rotate the text 90Deg and then test for the width ?...
This SO answer is probably over-engineered for your needs How can you find the height of text on an HTML canvas?
I prefer something a little more simple:
var text = "Hello World";
var font = "Serif";
var size = "16";
var bold = false;
var div = document.createElement("div");
div.innerHTML = text;
div.style.position = 'absolute';
div.style.top = '-9999px';
div.style.left = '-9999px';
div.style.fontFamily = font;
div.style.fontWeight = bold ? 'bold' : 'normal';
div.style.fontSize = size + 'pt'; // or 'px'
document.body.appendChild(div);
var size = [ div.offsetWidth, div.offsetHeight ];
document.body.removeChild(div);
// Output
console.log( size );
var pre = document.getElementById( "output" );
if( pre )
pre.innerHTML = size;
<pre id="output"></pre>
Reference: http://www.rgraph.net/blog/2013/january/measuring-text-height-with-html5-canvas.html