public static class LineWrapperFills a paragraph's break opportunities into lines of a given width.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
The half LineBreaker deliberately does not do. That one answers "where may a line end", which is a question about Unicode and is judged by a conformance suite that has never heard of a font; this one answers "where does it end", which needs measured widths and cannot be judged that way at all. Keeping them apart is what let the first be gated properly.
⚠ Greedy, first-fit. Knuth–Plass minimises the raggedness of a paragraph as a whole and is what a typesetter wants; a user interface reflows on every resize and every keystroke, and paying for an optimum that changes as fast as it is computed is the wrong trade. It is also what every browser does, so text in a panel wraps where somebody expects it to.
Methods (4)
public static void Wrap(ShapedText shaped, float maxAdvance, List<WrappedLine> lines, TextWrapMode mode = Word)Wraps a shaped paragraph to a width.
public static void Wrap(string text, ReadOnlySpan<float> advances, float maxAdvance, List<WrappedLine> lines, TextWrapMode mode = Word)Wraps a paragraph whose widths the caller measured.
public static List<WrappedLine> Lines(ShapedText shaped, float maxAdvance, TextWrapMode mode = Word)Wraps a shaped paragraph to a width.
public static float[] Advances(ShapedText shaped)The advance of every character, indexed by its position in the source.
Used by (2)
- LineWrapTestsVixen.Ui.Text.Tests
- UiElementVixen.Ui