Added function to truncate string if it doesn't fit in the desired rectangle