How a 7‑Day Imprisonment Fueled the GPU‑Accelerated Text Engine Used by Billions
The article recounts how engineer Behdad Esfahbod endured a week of solitary confinement for refusing to inform on activists, then spent five years building HarfBuzz—a GPU‑accelerated text‑shaping library that now powers text rendering on billions of devices, detailing its technical evolution, security record, and global impact.
HarfBuzz overview
HarfBuzz is an open‑source text shaping engine integrated into Android, Chrome, Firefox, Microsoft Edge, GNOME, KDE, LibreOffice, Figma, Canva, Godot, Unreal, Unity 6, Amazon Kindle, PlayStation, smart‑TV firmware, and automotive dashboards. The GitHub repository has approximately 5,500 stars.
Shaping vs rendering
Shaping determines which glyph form belongs at each position; rendering converts the positioned glyphs into pixels. For example, the letters i and f form a ligature that replaces two characters with a single combined glyph. Shaping also handles language‑specific behaviors such as Arabic contextual forms, Devanagari conjuncts, and Persian zero‑width joiners.
GPU‑accelerated rendering path
For a decade developers could not achieve correct GPU text rendering. In 2016 Eric Lengyel invented the Slug algorithm, which encodes Bézier curve data into compact “bands” uploaded to the GPU and evaluated per‑pixel in a fragment shader, eliminating the need for bitmap atlases or signed‑distance‑field approximations. US patent 10,373,352 expired in March 2026, allowing open‑source adoption.
HarfBuzz 14.0 release
HarfBuzz 14.0, released in April 2024 (maintenance update 14.1 three days later), bundles libharfbuzz‑gpu and supports four shader languages: GLSL (OpenGL/WebGL), WGSL (WebGPU), MSL (Apple Metal), and HLSL (DirectX). A live demo is available at https://harfbuzz.github.io/hb-gpu-demo. The GPU path replaces the traditional CPU rasterization pipeline, enabling crisp text at any scale, perspective, or zoom level across browsers, game engines, automotive displays, and AR headsets.
Performance impact
Memory usage drops because bitmap caches are no longer required.
On a typical Android phone the GPU path eliminates up to one second of “catch‑up” rendering during rapid pinch‑zoom.
On a laptop scrolling a 4K Reddit feed the GPU path prevents the fan from running at full speed.
Security record
Since its inception HarfBuzz has fewer than ten publicly disclosed security issues, most of which are denial‑of‑service vulnerabilities, compared with nearly one hundred issues reported for FreeType.
Future development
The project is adding HarfRust, a memory‑safe Rust port whose performance is within 25 % of the C++ implementation. Maintenance is performed by a small, globally distributed team.
Historical shaping challenges
In the 1990s Persian text suffered from five incompatible encodings (ISIRI 2900, Iran System, ISIRI 3342, FSCII, Windows 1256). The FarsiWeb project contributed code to GNOME, Firefox, OpenOffice, Wikipedia, Fedora, FriBidi, and glibc, leading to the ISIRI 6219 Unicode‑based standard in 2002, which resolved the display issues.
Technical pipeline illustration
Traditional pipeline: CPU runs HarfBuzz to select glyphs, rasterizes each glyph to a bitmap, uploads the bitmap as a texture, and GPU draws textured quads. New pipeline: CPU runs HarfBuzz to obtain Bézier curve data, encodes it into bands, uploads bands once per font, and GPU fragment shaders evaluate the exact curve for each pixel.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
