What does the library do?
Pretext helps prepare and measure multiline text so developers can build interfaces where layout behavior is a first-class system instead of an afterthought.
About The Platform
This site is not the official Pretext project website. It is an independent platform that explains what Pretext is, shows what can be built with it, and connects the underlying open source library to live browser projects.
What Is Pretext?
The original Pretext project is an open source library created by chenglou. It is useful when you need precise text measurement, layout preparation, text segmentation, and reflow logic across browser-driven experiences such as Canvas interfaces, custom typography systems, interactive text tools, and browser games.
Pretext helps prepare and measure multiline text so developers can build interfaces where layout behavior is a first-class system instead of an afterthought.
This platform exists to show what can be built with Pretext in practice, not just describe the library in theory. Every project here is a real application of that layout capability.
Pretext is the underlying open source library. This site is an independent platform built with it, and Text Invaders, Text Pong, plus Text MDR are three live experiences on the platform.
Featured Games
Pretext now has three live games. Text Invaders turns words into destructible enemies, Text Pong turns terminal visuals into a fast reflex game, and Text MDR applies the same platform to dossier-based text refinement. All three are built around the same text-first platform logic.
An ASCII-style browser game where text becomes the battlefield. Players shoot through live words and trigger dynamic reflow as the layout breaks apart and reforms.
A terminal-inspired Pong variant that keeps the same platform shell and text-forward visual language, but applies it to a different arcade loop focused on timing, deflection, and screen rhythm.
A macrodata refinement game inspired by Severance, built around dense dossiers, anomaly tracking, and text stabilization. It shows the platform can support slower, more systemic text play.
The platform is designed to expand beyond these three games. Future releases can include more experiments, layout demos, and interactive tools built on the same Pretext-driven rendering foundation.
Platform Features
A full-screen canvas experience wrapped in a text-first shell with CRT-inspired overlays, menus, and HUD panels.
Text Invaders, Text Pong, and Text MDR already share a common platform frame, which makes the homepage a true game collection instead of a single-project landing page.
Pretext prepares and positions text segments so gameplay, layout behavior, and rendering can all rely on the same text-aware foundation.
When text changes during play, the surrounding structure can respond instead of staying fixed, which is central to the platform identity.
The homepage can support more projects, examples, and dedicated landing pages as the Pretext catalog grows.
The platform combines playable demos with clear explanations, which helps both traditional search engines and AI answer engines understand what the site offers.
How It Works
Built With
The platform is built as a fast-loading TypeScript project with a lightweight Vite toolchain.
Gameplay, shell transitions, particles, and text-driven visuals are rendered directly in browser-native surfaces.
Pretext handles the text layout foundation that makes segment-aware positioning, dynamic text behavior, and experimental interaction patterns possible.
Platform Comparison
FAQ
Pretext is a JavaScript and TypeScript library for multiline text measurement and layout. It is the open source foundation behind the projects featured on this site.
No. The official Pretext project lives on GitHub under chenglou/pretext. This site is an independent platform that showcases projects built with the library.
The platform currently features three games: Text Invaders, Text Pong, and Text MDR. More projects can be added on top of the same runtime and Pretext-powered interaction model.
They use Pretext as a text-aware foundation for layout preparation and browser-native interaction. Text Invaders pushes harder into live text reflow, Text Pong demonstrates the broader platform shell, and Text MDR applies Pretext to dense dossier-based refinement gameplay.