math - Mathematical Formula for working out font size -


can me i'm not having luck want try workout ideal fontsize text based on width of image it's overlaying , amount of characters in text string. me formula this.

i got semi-working due infinite monkey theorem!

// gets text1 count  $charcount = strlen($line1); // gets text1 size count $newsize = ($width / floor($charcount)); $add = ( 20 % $newsize ); $newsize = ($newsize + $add);  // changes font size $text1->setfontsize( $newsize ); 

i use based on width or height of image:

 resize_font = function () {     // play around denominator until font size want   var fontsize = parseint($("#your_image_div").width()) / 2 + "%";       //then apply css text div element   $(".your_text_class").css('font-size', fontsize);    };          // hook whatever event want           $(document).ready(resize); 

hope helps. trick handy making elements resize in relation veiwport too. hope helps.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -