59
I don't know of an exact way, but here's an approximation:
var factor = 1/3; // approximate width-to-height ratio
var div = $('#mydiv');
div.css('font-size', div.width() / (div.text().length * factor) + 'px');
You will need to adjust factor based on the font you are using. 1/3 seems to work okay for Times New Roman.