Given a string of any length in any font (not necessarily monospace, preferably Arial) I need a way to find the font size that will make the text fit perfectly into a specific pixel width, say 500 for example.
I'd MUCH prefer if there were a way to do this without using any libraries, CSS, or html. Pure JavaScript.
Thanks in advance!
P.S. I've heard of ctx.measureText(string).width but I couldn't figure out if it was helpful or not...