Code to calculate perfect size for a label