Building blocks for advanced wrapping functionality.
In general, you want to follow these steps when wrapping something:
Potentially split your fragments into smaller pieces. This allows you to implement things like hyphenation. If wrapping text,
split_wordscan help you do this.
Potentially break apart fragments that are still too large to fit on a single line. This is implemented in
Iterate through the slices returned by the wrapping functions and construct your lines of output.
Please open an issue if the functionality here is not sufficient or if you have ideas for improving it. We would love to hear from you!
A piece of wrappable text, including any trailing whitespace.
A (text) fragment denotes the unit which we wrap into lines.
Forcibly break words wider than
Compute the display width of
Split line into words separated by regions of
Split words into smaller words according to the split points given
Wrap abstract fragments into lines with a first-fit algorithm.
Wrap abstract fragments into lines with an optimal-fit algorithm.