Pretext is a deterministic text preparation and line-layout engine with pluggable text-measurement backends. It prepares text once, exposes segment and break metadata, and lets you compute line counts, materialized lines, or streamed line geometry without relying on control reflow.
`Prepare` and `PrepareWithSegments` precompute widths, break opportunities, and whitespace behavior so repeated layout passes stay cheap.
Use `Layout` for quick metrics, `LayoutWithLines` for materialized lines, or `LayoutNextLine` and `WalkLineRanges` for incremental custom layout engines.
The engine handles grapheme-aware breaks, discretionary hyphens, tabs, preserved whitespace, bidi text, and locale-aware segmentation on desktop targets.
Pretext is a layout engine, not a text renderer. It answers questions such as:
You still own:
Install the packages, learn the font string contract, and build the first useful `Prepare` + `Layout` flow.
Open sectionUnderstand the prepared-text lifecycle, whitespace modes, break kinds, locale-aware segmentation, bidi, and line fitting.
Open sectionIntegrate `Pretext` into Uno, native Windows/Linux/macOS hosts, or any SkiaSharp-based renderer, then reuse the shared sample-host patterns for shrinkwrap, editorial, and obstacle-aware layouts.
Open sectionBrowse every public type and operation, the package-by-package reference pages, platform notes, and repository structure.
Open section| Path | Purpose |
|---|---|
src/Pretext |
The packable library project containing PretextLayout and the text preparation/layout pipeline. |
src/Pretext.Contracts |
Shared backend contracts and first-party font-string parsing helpers. |
src/Pretext.Layout |
Platform-neutral wrap and obstacle-layout helpers built on top of Pretext. |
src/Pretext.DirectWrite |
Windows DirectWrite measurement backend. |
src/Pretext.FreeType |
Linux FreeType + Fontconfig measurement backend. |
src/Pretext.CoreText |
macOS CoreText measurement backend. |
src/Pretext.SkiaSharp |
Portable SkiaSharp measurement backend and fallback. |
src/Pretext.Uno |
The source for the Pretext.Uno package, with Uno-specific reusable controls and render scheduling helpers. |
tests/Pretext.Uno.Tests |
Deterministic parity tests for whitespace handling, break behavior, bidi text, and line walking. |
samples/PretextSamples.Shared |
Shared sample catalog, assets, and data/model layer reused by the sample hosts. |
samples/PretextSamples.Uno |
A Uno sample host with layout demos including bubbles, masonry, editorial, and justification views. |
samples/PretextSamples.MacOS |
A native AppKit sample host on net10.0-macos using Pretext.CoreText. |
| Package | Purpose |
|---|---|
Pretext |
Backend-agnostic text preparation and layout engine. |
Pretext.Contracts |
Public backend contracts and shared font parsing. |
Pretext.Layout |
Platform-neutral wrap and obstacle-layout helpers. |
Pretext.DirectWrite |
Windows-native DirectWrite backend. |
Pretext.FreeType |
Linux-native FreeType + Fontconfig backend. |
Pretext.CoreText |
macOS-native CoreText backend. |
Pretext.SkiaSharp |
Portable SkiaSharp backend and fallback. |
Pretext.Uno |
Uno-specific controls layered on top of Pretext. |