Javascript convertir ancho y alto a tamaño de fuente

No estoy seguro de que esta pregunta ya haya sido formulada y respondida, pero no he encontrado ningún resultado relevante.

¿Me gustaría saber si es posible calcular y convertir dimensiones específicas (ancho / alto) a un tamaño de fuente?

Por ejemplo, tengo:

var textWidth = 150;
var textHeight = 30;

¿Y me gustaría obtener un tamaño de fuente de estas dimensiones (píxeles)?

EDIT: Gracias Dystroy, finalmente logré resolver este problema con su ayuda. Utilicé la función publicadaaquí Y después de eso, no fue muy complicado:

$(function(){

            $( "#height, #width" ).keyup(function(){

                var varHeight = $( "#height" ).val();
                var varWidth = $( "#width" ).val();

                if(  varHeight != "" && varWidth != "" ){

                    $( "#text_container" ).css( "width", varWidth );    
                    $( "#text_container" ).css( "height", varHeight );

                    $( "#text_container" ).textfill({ maxFontPixels: 500 });

                    var getFontsize = $( "#text_container > span" ).css( "font-size" );
                    var fontSize = parseInt( getFontsize.slice(0, -2) );

                    $( "#fontsize" ).val( fontSize );

                }

            });

        });

Gracias de nuevo.

Respuestas a la pregunta(1)

Su respuesta a la pregunta