ghostty-org/ghostty
LoadFlags misaligned with FreeType FT_LOAD_* flags (missing ADVANCE_ONLY; cascade shift)
Summary
Context: The
LoadFlagspacked struct inpkg/freetype/face.zigis a Zig wrapper for FreeType’sFT_LOAD_*bit flags, used to control glyph loading behavior when rendering fonts.Bug: The struct is missing the
FT_LOAD_ADVANCE_ONLYflag at bit position 8, causing all subsequent flag fields (bits 8-24) to be misaligned by at least one bit position.Actual vs. expected: Field at bit 8 has typo
ignore_global_advance_withand should beadvance_only; field at bit 9 isno_recursebut should beignore_global_advance_width; all subsequent fields are similarly misaligned.Impact: Any code using LoadFlags with fields beyond bit 7 will pass incorrect flags to FreeType, potentially causing wrong rendering modes, incorrect hinting, or other glyph loading errors.
Code with bug
Codebase inconsistency
FreeType’s public API defines the load flags as:
In pkg/freetype/face.zig, bit 8 is ignore_global_advance_with instead of advance_only, and flags at bits 9–13 are shifted relative to the C API. The struct also lacks sbits_only (bit 14) and svg_only (bit 23). This mismatch ensures that any LoadFlags using bits ≥8 produce incorrect bitmasks compared to FreeType’s documented constants, confirming the bug.
Recommended fix
The struct should be corrected to match the FreeType C API exactly:
Important: The fix requires careful verification of bits 16-24, as there may be additional padding or encoding issues with the target_* and color flags. The existing test at lines 291-299 should be expanded to verify ALL flag positions match their C counterparts.
