Hello. For some text T and some number S, how can I determine the longest prefix T' of T such that the width of the image of T' is less than S? The practical aim is to break T into lines which fit in a rectangle.