Consider following problem :
Given:
- String input with the length n
- Font(-metrics) - potentially slow in usage
- Bounds of an abstract Textview which shall contain the text in a specific manner: e.g not breaking any word in the middle but rescaling the lines and/or break the line at another position.
The font-size has to be calculated in dependance of the input (because there are glyphs which are bigger than others) and the font. The line breaks will have to be after word endings.
Furthermore it is to be noted that the solution has to be highly efficient in terms of avoiding calculating redundantly etc.
The length of the string is not known and can be something between 1200 pages to 1 or 2 lines long.
Desired:
An approach which will have to yield these informations :
- the indices of the line breaks
- the font-size
What would be a reasonable approach ? Is there a way to reuse calculated values (dynamic programming) ? Are there standard algorithms for this ?