Flattype

OpenType Text Shaper and Renderer

Flattype is an all-in-one text layout engine that performs full complex text layout and rendering in 35 KB of gzipped JavaScript or a 170 KB size-optimized Rust binary. It supports bidirectional text, complex scripts like Arabic and Indic, and advanced OpenType features, while remaining small enough to run everywhere from web applications to embedded systems like the ESP32.

44 21 24 9 19 3 15 22 25 27 19
Font: IBM Plex Serif, generic fill text

Pre-release. Flattype is in the final stage of development. The release date and license terms have not been decided yet.

Compact by Design

Flattype combines the entire layout and rendering pipeline in one library. It resolves bidirectional text into visual order, shapes it to select and position the glyphs, then pulls their outlines from the font and turns them into a path description, ready to render.

It does all of this in very little space. Because Flattype was written from scratch for this purpose, it carries nothing it does not need. The JavaScript build is under 95 KB minified, 35 KB gzipped, with no runtime dependencies. The Rust build compiles to a 170 KB binary, or 270 KB if compiled for speed (size on flash, not RAM). It has full no_std support and no unsafe code. Runtime allocation is minimal, so even on very memory-constrained systems, multiple fonts can be used concurrently.

Complex text layouts

Flattype implements the full shaping pipeline: contextual substitution, ligatures, mark positioning, and script-specific reordering, with the layers interacting correctly rather than in isolation. It renders complex scripts correctly: Indic scripts like Devanagari and Bengali, Khmer, Thai, Arabic, Nastaliq, and more, as well as CJK.

285 317 79 48 641 702 533 475 49 1073 500 322 675 454 690 743 698 641 514 119 837 131 445 1045 131 1079 131 838 119 1076 241 119 119 119 837 131 842 445 131 837 1076 119
Font: Gulzar, meaning "their similar rectangles"

Support for all living scripts

Flattype aims to support every writing system in active use today. It currently supports more than 80 modern scripts, from Latin, Chinese, Devanagari, and Arabic to Cherokee, Adlam, N'Ko, and Canadian Aboriginal syllabics. The currently supported scripts are listed in full on the specification page.

305 396 281 225 193 329 389 313 172 280 403 403
Font: Noto Sans Adlam, Meaning "educational/academic"

Performance

Performance depends on the script, font, and text being shaped. In our benchmarks, the Rust/WASM implementation of Flattype consistently runs within a factor of two of the native C++ HarfBuzz implementation. The JavaScript version is generally around twice as slow again, trading some performance for portability, simplicity, and a 35 KB gzipped download size.

Where Flattype Fits

Flattype isn't looking to replace HarfBuzz, the industry standard powering Android, Chrome, and Firefox. Instead, Flattype is an alternative for environments where HarfBuzz is simply too large and complex, or entirely unsupported.

  • Embedded Hardware
    Run advanced text shaping on devices where another full shaper won't fit, like the ESP32.
  • The Modern Web
    Skip the heavy multi-hundred-kilobyte WebAssembly blobs. Flattype's 35 KB gzipped JS build loads fast and runs natively, with no WASM to fetch or compile. Edit without recompiling and debug straight in the browser.
  • Approachable and Extensible
    The codebase is small enough to understand and modify without navigating a large C++ codebase.

Key Features

  • JavaScript version
    Web, Node.js, and WebAssembly. Under 95 KB minified, 35 KB gzipped. No runtime dependencies.
  • Rust version
    Embedded systems, desktop, games, and native applications. 170 KB binary on flash, 270 KB if optimized for speed. No unsafe code, full no_std support.
  • Complex and bidirectional text layout
    Supports ligatures, complex script layout like Arabic, Indic, Khmer, Thai
  • Heavily tested
    Verified against HarfBuzz's shaping test suite and 700+ additional tests covering many edge cases.
  • Standard font formats
    Supports OpenType (OTF) and TrueType (TTF)

Advanced Typography in Embedded Environments

To show what this looks like in practice, we built a demo on the Cheap Yellow Display, a low-cost ESP32 board with a small touchscreen. It runs complex scripts and bidirectional text with multiple fonts at once, on a board with just 320 KB of data RAM.

Flattype rendering "Lorem ipsum dolor sit" on a Cheap Yellow Display touchscreen
Flattype running on the Cheap Yellow Display

Try it in the Hyvector App

Flattype powers the typography in Hyvector, a web-based vector editor. It handles bidirectional text input with a bidi-aware cursor, automatic font fallback across all supported scripts, and conversion of shaped text into clean, editable vector paths.

The Hyvector editor showing mixed Latin and Arabic (bidirectional) text with per-span coloring
Bidirectional text editing in Hyvector

Where we are, where we're headed

Flattype is feature-complete and currently in pre-release: full complex shaping, bidirectional layout, and rendering, in both the JavaScript and Rust builds. It already runs in production in Hyvector, and on embedded hardware as a demo.

What remains open is how it ships. We are currently looking for a way to fund either an open-source release or commercial licensing, and we would rather get that right than rush it. If you have a use for Flattype, commercial or otherwise, we would like to hear from you.