I'm not sure if this question has already been asked and answered but I haven't found any relevant result.
I would like to know if it's possible to calculate and convert specific dimensions (width/height) to a font-size ?
For example, I have :
var textWidth = 150;
var textHeight = 30;
And I would like to get a font-size from these dimensions (pixels)?
EDIT : Thanks dystroy, I finally managed to resolve this issue with your help. I used the function posted here and after that, it was not very complicated :
$(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 );
}
});
});
Thanks again.