Swift at Apple: Migrating the TrueType Hinting Interpreter
Summary
Apple migrated the TrueType hinting interpreter from C to memory-safe Swift to improve security and performance. The project required binary compatibility so that existing programs still render glyphs identically. They defined correctness as exact compatibility with the C outputs. They used unit tests and a fuzzing workflow that processed 10 million PDF files across 25,572 fonts to ensure compatibility. The team developed safe interop techniques to bridge C and Swift without unnecessary copying, and achieved a notable performance improvement, with Swift running about 13% faster on average. They published the Swift implementation source code on GitHub for others to study.