I'm drawing text in an HTML5 canvas on top of an image (a meme generator). I want to calculate a font size so that the string will span the entire width of the canvas. 

So basically, is there a way in JavaScript to determine what font size I should use for some string of a certain font for a given width?