# Pretext ## Docs - [clearCache()](https://mintlify.wiki/chenglou/pretext/api/clear-cache.md): Clear Pretext's shared internal caches to free memory or reset state. - [layout()](https://mintlify.wiki/chenglou/pretext/api/layout.md): Compute text height from a PreparedText handle. Pure arithmetic — no DOM, no canvas. - [layoutNextLine()](https://mintlify.wiki/chenglou/pretext/api/layout-next-line.md): Step through a paragraph one line at a time with variable widths per line. - [layoutWithLines()](https://mintlify.wiki/chenglou/pretext/api/layout-with-lines.md): Lay out a paragraph and get the text content and width of each line. - [prepare()](https://mintlify.wiki/chenglou/pretext/api/prepare.md): Segment and measure text for fast DOM-free layout. Call once per text block. - [prepareWithSegments()](https://mintlify.wiki/chenglou/pretext/api/prepare-with-segments.md): Rich variant of prepare() that exposes segment data for manual line rendering. - [setLocale()](https://mintlify.wiki/chenglou/pretext/api/set-locale.md): Set the locale for Intl.Segmenter used in future prepare() calls. - [Types](https://mintlify.wiki/chenglou/pretext/api/types.md): TypeScript type definitions for all public Pretext APIs. - [walkLineRanges()](https://mintlify.wiki/chenglou/pretext/api/walk-line-ranges.md): Iterate over line geometry without building line text strings. Ideal for shrinkwrap layouts. - [How Pretext works](https://mintlify.wiki/chenglou/pretext/concepts/how-it-works.md): The two-phase architecture behind DOM-free text measurement. - [Line breaking](https://mintlify.wiki/chenglou/pretext/concepts/line-breaking.md): How Pretext implements CSS-compatible line breaking across all scripts. - [Text measurement](https://mintlify.wiki/chenglou/pretext/concepts/text-measurement.md): How Pretext measures text segments using canvas and handles browser-specific quirks. - [Predicting paragraph height](https://mintlify.wiki/chenglou/pretext/guides/height-prediction.md): Use prepare() and layout() to measure text height without touching the DOM. - [Internationalization](https://mintlify.wiki/chenglou/pretext/guides/internationalization.md): How Pretext handles CJK, Arabic, Thai, emoji, and other scripts. - [Manual line layout](https://mintlify.wiki/chenglou/pretext/guides/manual-layout.md): Use prepareWithSegments and layoutWithLines to render text to canvas, SVG, or WebGL. - [Variable-width layout](https://mintlify.wiki/chenglou/pretext/guides/variable-width-layout.md): Use layoutNextLine() to route text one row at a time when width changes as you go. - [Whitespace modes](https://mintlify.wiki/chenglou/pretext/guides/whitespace-modes.md): Control how Pretext handles spaces, tabs, and line breaks. - [Pretext](https://mintlify.wiki/chenglou/pretext/index.md): Fast, accurate multiline text measurement and layout for the browser — no DOM reflow required. - [Installation](https://mintlify.wiki/chenglou/pretext/installation.md): Install Pretext via npm, yarn, or pnpm. - [Introduction](https://mintlify.wiki/chenglou/pretext/introduction.md): Pretext is a pure JavaScript/TypeScript library for fast, accurate multiline text measurement and layout — without DOM reflow. - [Accuracy](https://mintlify.wiki/chenglou/pretext/performance/accuracy.md): How Pretext validates against real browser layout and current accuracy status. - [Benchmarks](https://mintlify.wiki/chenglou/pretext/performance/benchmarks.md): Performance numbers for prepare() and layout() across browsers and text corpora. - [Caching](https://mintlify.wiki/chenglou/pretext/performance/caching.md): How Pretext caches segment widths and how to manage cache lifecycle. - [Quickstart](https://mintlify.wiki/chenglou/pretext/quickstart.md): Measure your first paragraph height in under a minute.