Interactive text games and experiments built with Pretext .

What Is Pretext?

Pretext is a JavaScript and TypeScript library for multiline text measurement and layout.

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.

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.

Why does this platform exist?

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.

How should users think about the relationship?

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.

Key facts at a glance

  • Library: Pretext by chenglou
  • Platform: independent site built with Pretext
  • Live projects: Text Invaders, Text Pong, and Text MDR
  • Focus: interactive text games and browser experiments

Platform Features

The platform is organized around reusable Pretext-powered interaction patterns.

ASCII terminal-style game UI

A full-screen canvas experience wrapped in a text-first shell with CRT-inspired overlays, menus, and HUD panels.

Multiple games on one runtime shell

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-powered text layout logic

Pretext prepares and positions text segments so gameplay, layout behavior, and rendering can all rely on the same text-aware foundation.

Dynamic reflow and live interaction

When text changes during play, the surrounding structure can respond instead of staying fixed, which is central to the platform identity.

Platform-ready content expansion

The homepage can support more projects, examples, and dedicated landing pages as the Pretext catalog grows.

Search-friendly explanation layer

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

The platform starts with text layout and turns it into game systems.

  1. Pretext measures and prepares multiline text so the platform can reason about layout before anything is drawn.
  2. That layout data is mapped into game-specific systems such as enemies, paddles, overlays, and runtime UI.
  3. Each game uses the shared platform shell while applying different gameplay logic on top of the same text-aware foundation.
  4. The result is a collection of browser-native projects where text is not just content, but an active part of the interaction model.

Built With

Pretext combines a shared runtime with the Pretext layout library and browser-native rendering.

TypeScript + Vite

The platform is built as a fast-loading TypeScript project with a lightweight Vite toolchain.

HTML5 Canvas

Gameplay, shell transitions, particles, and text-driven visuals are rendered directly in browser-native surfaces.

@chenglou/pretext

Pretext handles the text layout foundation that makes segment-aware positioning, dynamic text behavior, and experimental interaction patterns possible.

Platform Comparison

Pretext is not just one browser game and not the official Pretext project site.

Dimension
Pretext Library
Pretext Platform
Primary role
Open source text layout library
Independent platform for games and experiments built with that library
Audience
Developers building text-aware interfaces
Players, designers, developers, and creative coders exploring what Pretext enables
Output
Layout data, measurement, and text segmentation
Playable browser projects such as Text Invaders, Text Pong, and Text MDR
Site intent
Official open source library reference
Project showcase, explanation layer, and platform homepage

FAQ

Clear answers for search engines, AI tools, and curious developers.

What is Pretext?

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.

Is this the official Pretext website?

No. The official Pretext project lives on GitHub under chenglou/pretext. This site is an independent platform that showcases projects built with the library.

What projects are currently available on the platform?

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.

How do the platform games use Pretext?

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.