updated the adjustFontSize function to include more checks