fixed text length calculation bug