Two recurring patterns in the sample hosts are worth copying into your own code.
Use WalkLineRanges or LayoutWithLines to find the exact width of the longest line, then size the host element to that width instead of relying on default control measurement.
This pattern is useful for:
Typical flow:
PrepareWithSegments onceMaxLineWidthUse LayoutNextLine when content must flow around obstacles or into fixed slots. Because the API returns one line at a time, you can decide where to place the next line, how much width remains, and whether a region should continue into a second column or frame.
Typical flow:
LayoutNextLine(prepared, cursor, slotWidth)Both patterns depend on the same property of Pretext: width-dependent layout is cheap after preparation, so you can build higher-level algorithms without reparsing the paragraph.
In Pretext.Layout, these helpers support the same patterns:
PreparedTextMetricsColumnFlowLayoutObstacleLayoutHelper