Converting PostScript CFF Cubic Splines into TrueType Quadratic glyf Tables
Why Renaming .otf to .ttf Fails Embedded Rasterizers and Game Engines
Simply changing a font filename extension from .otf to .ttf leaves the 4-byte OTTO header and PostScript Type 2 CFF charstring table untouched inside the binary. While modern desktop operating systems inspect magic bytes rather than extensions, legacy CAD plotters, Android custom canvas loaders, embedded FreeType builds compiled without CFF modules, and older Office PDF pipelines strictly demand quadratic TrueType glyf and loca tables.
True outline conversion requires translating degree-3 cubic Bézier segments into degree-2 quadratic Bézier splines. Our local Worker parses every CFF charstring in font design coordinates and recursively subdivides cubic curves via De Casteljau midpoint splitting until the degree-reduction residual drops below 0.5 font units.
- Reverses PostScript counter-clockwise outer contour winding into TrueType clockwise winding.
- Upgrades the 6-byte CFF maxp v0.5 table to a full 32-byte TrueType maxp v1.0 profile and writes 32-bit format-1 loca offsets.
- Preserves original cmap character mappings, hmtx horizontal advances, OS/2 vertical metrics, GPOS kerning, and SIL OFL Name IDs.
- Normalizes every 16-byte SFNT directory checksum plus head.checkSumAdjustment to 0xB1B0AFBA.