Pretext

Pretext is a deterministic text preparation and line-layout engine for any SkiaSharp-based UI. 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.

What This Library Does

Prepare once, reuse often

`Prepare` and `PrepareWithSegments` precompute widths, break opportunities, and whitespace behavior so repeated layout passes stay cheap.

Batch and streaming layout

Use `Layout` for quick metrics, `LayoutWithLines` for materialized lines, or `LayoutNextLine` and `WalkLineRanges` for incremental custom layout engines.

Real text behavior

The engine handles grapheme-aware breaks, discretionary hyphens, tabs, preserved whitespace, bidi text, and locale-aware segmentation on desktop targets.

Scope

Pretext is a layout engine, not a text renderer. It answers questions such as:

  • how many lines fit in a given width
  • what text ends up on each line
  • where the next line should start for a custom flow algorithm
  • which whitespace, punctuation, and discretionary break opportunities should stay visible

You still own:

  • drawing the text in your host UI
  • choosing the line height and baseline policy
  • arranging lines into columns, cards, obstacles, or custom panels
  • invalidating or repainting your UI when layout inputs change

Documentation Map

Getting Started

Install the packages, learn the font string contract, and build the first useful `Prepare` + `Layout` flow.

Open section

Concepts

Understand the prepared-text lifecycle, whitespace modes, break kinds, locale-aware segmentation, bidi, and line fitting.

Open section

Guides

Integrate `Pretext` into Uno or any SkiaSharp-based host, and reuse the sample app patterns for shrinkwrap, editorial, and obstacle-aware layouts.

Open section

Reference

Browse every public type and operation, the `Pretext.Uno` companion helpers, platform notes, and repository structure.

Open section

Repository Layout

Path Purpose
src/Pretext The packable library project containing PretextLayout and the text preparation/layout pipeline.
src/Pretext.Uno The source for the Pretext.Uno package, with Uno-specific reusable controls and layout helpers.
tests/Pretext.Uno.Tests Deterministic parity tests for whitespace handling, break behavior, bidi text, and line walking.
samples/PretextSamples A Uno sample app with layout demos including bubbles, masonry, editorial, and justification views.

Published Packages

Package Purpose
Pretext Core SkiaSharp-based text preparation and layout engine.
Pretext.Uno Uno-specific controls and helpers layered on top of Pretext.

Start With These Pages

Repository