HeadlinesBriefing favicon HeadlinesBriefing.com

TrueType Font Turns Into Tiny 3‑D Engine

Hacker News •
×

A developer named 4RH1T3CT0R7 has embedded a 3‑D raycasting engine inside a TrueType font’s hinting virtual machine. The glyph “A” contains 16 vertical bars that the hinting code repurposes to draw a crude Wolfenstein‑style view. The entire engine occupies just 6.5 KB of bytecode and runs on the tiny VM that Apple shipped in 1991 today.

JavaScript supplies movement, enemies, and shooting logic, then pushes the player’s X, Y, and angle into the font via CSS font‑variation‑settings. Each frame the browser re‑hints the glyph, causing the hinting code to perform DDA ray‑marching against a 16×16 tile map stored in the VM’s 795‑slot storage area. The result looks like a low‑resolution first‑person shooter.

Writing the engine required a custom compiler that translates a C‑like domain‑specific language into TrueType assembly. The compiler had to work around quirks such as the MUL instruction performing (a*b)/64, the absence of WHILE loops, and the fixed‑point arithmetic that forces values into an F26Dot6 format. Despite these hurdles, the project demonstrates the VM’s Turing‑completeness.

The demo, hosted on GitHub Pages, lets users control the view with WASD and arrow keys, fire with Space, and toggle a debug overlay with Tab to reveal the font’s variation axes in real time. By turning a font into a miniature GPU, the work showcases how legacy technologies can still inspire playful experimentation today.