Javascript converter largura e altura para tamanho da fonte

Não tenho certeza se essa pergunta já foi feita e respondida, mas não encontrei nenhum resultado relevante.

Gostaria de saber se é possível calcular e converter dimensões específicas (largura / altura) em tamanho de fonte?

Por exemplo, eu tenho:

var textWidth = 150;
var textHeight = 30;

E gostaria de obter um tamanho de fonte dessas dimensões (pixels)?

EDIT: Obrigado dystroy, eu finalmente consegui resolver esse problema com sua ajuda. Eu usei a função postadaAqui e depois disso, não foi muito 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 );

                }

            });

        });

Obrigado novamente.

questionAnswers(1)

yourAnswerToTheQuestion