Pretext exposes more than one way to consume layout because different consumers need different output shapes.
Use Layout when you only need:
Use LayoutWithLines when you need:
This is the easiest API to use, but it allocates strings for every line.
Use LayoutNextLine when you want to drive your own loop and stop early, and use WalkLineRanges when you only need geometry without allocating full line strings.
| API | Returns | Best for |
|---|---|---|
Layout |
LayoutResult |
fast measurement passes |
LayoutWithLines |
LayoutLinesResult |
simple rendering and diagnostics |
LayoutNextLine |
one LayoutLine at a time |
columns, obstacles, stop-early custom loops |
WalkLineRanges |
widths and cursors only | allocation-sensitive geometry passes |
LayoutNextLine advances through a paragraph using LayoutCursor:
SegmentIndex identifies the current prepared segmentGraphemeIndex identifies the offset inside a breakable segmentThat is what makes overlong words, discretionary hyphens, and obstacle-aware layout work without losing alignment with LayoutWithLines.
Some segment kinds behave differently when they are fitted versus painted:
PreWrapThat difference is already reflected in the public LayoutLine.Width and LayoutLineRange.Width values.
Those APIs are what make the sample gallery possible: bubbles, masonry cards, and editorial layouts can reuse the same prepared text but consume it differently.