HarfBuzz + FreeType on bare-metal: GSUB shaping causes hard fault

2026-06-11

Stack Overflow: View Question

Tags: memory-management, embedded, memory-address, nxp-microcontroller, harfbuzz

Score: 0 | Views: 88

The asker is porting HarfBuzz 8.3.0 + FreeType 2.13.2 + LVGL to an NXP i.MX RT1064 Cortex-M7 in a bare-metal configuration (no MMU-backed OS). Latin and simple scripts shape fine, but as soon as they feed an Indic script through HarfBuzz, the MCU hits a hard fault. Their suspicion is recursive GSUB lookups blowing the stack or dereferencing into invalid memory.

This is a deeply interesting embedded problem because it sits at the intersection of three painful constraints:

Direction toward a solution:

Gotchas: FreeType's FT_Stream with custom I/O is a common silent failure — returning fewer bytes than requested makes HarfBuzz read garbage offsets. Also, HarfBuzz uses setjmp-free recursion; there's no graceful "out of stack" path, so detection must happen externally via MPU.

The challenge: Bare-metal Indic text shaping forces you to fit one of the most allocation- and recursion-heavy code paths in modern typography onto a Cortex-M with no MMU and a single-digit-KB stack.

All newsletters