What programming language are you using?
You could use
http://us2.php.net/manual/en/function.strlen.php
And then create an if statement to use this display with this font or that display with another font based on length.
Example:
<?php
$str = 'abcdef';
echo strlen($str);
if ($str >= 5){
?>
<font face="arial">Arial font because its greater then or equal 5</font>
<?
} else {
?>
<font face="tahoma">Tahoma font because its less then 5</font>
<?
}
?>