Skip to content

fix: implement deferred libeot-parity items (#7) - #8

Merged
ChristopherVR merged 1 commit into
mainfrom
fix/issue-7-libeot-parity
Jul 17, 2026
Merged

fix: implement deferred libeot-parity items (#7)#8
ChristopherVR merged 1 commit into
mainfrom
fix/issue-7-libeot-parity

Conversation

@ChristopherVR

Copy link
Copy Markdown
Owner

Implements all five deferred libeot-parity items tracked in #7.

Changes

  1. Byte-boundary enforcement (stream.ts) — byte read/write/seek now throw EOT_OFF_BYTE_BOUNDARY when the stream is mid-byte (bitPos != 0). readNBits remains the sole legitimate mid-byte accessor. Seeks require alignment rather than silently resetting bitPos, mirroring libeot.
  2. Bbox accumulator (ctf-parser.ts) — folds in the int16-truncated deltas, matching libeot and the coordinates the glyph actually renders with. No effect on valid input.
  3. Reserved-space errors (stream.ts)*ThroughReserve seeks throw EOT_SEEK_PAST_EOS and copyTo throws EOT_OUT_OF_RESERVED_SPACE instead of auto-growing. The glyph builder already pre-reserves worst-case space per glyph, so the decode path is unaffected.
  4. Missing head (sfnt-builder.ts)dumpContainer throws EotError NoHeadTable instead of silently skipping the checksumAdjustment patch.
  5. hdmx/VDMX diagnostics (ctf-parser.ts) — dropped tables surfaced via a new optional SFNTContainer.droppedTables field and an opt-in onWarn callback threaded through decompressMtx options (no console output, matching the library's existing convention).

API additions

  • New error codes: OffByteBoundary, OutOfReservedSpace, SeekPastEos.
  • New ParseCTFOptions type; parseCTF now exported.
  • decompressMtx gains options.onWarn (documented in README).

Verification

  • 222 tests pass (up from 214) — added coverage for byte-boundary throws, reserved-space errors, droppedTables/onWarn, and the missing-head guard; updated 11 sfnt-builder tests to include a head table.
  • tsup build succeeds; source is tsc-clean.

Closes #7

🤖 Generated with Claude Code

Address all five deferred parity findings from #7:

1. Byte-boundary enforcement (stream.ts): byte read/write/seek now throw
   EOT_OFF_BYTE_BOUNDARY when the stream is mid-byte; readNBits remains the
   sole legitimate mid-byte accessor. Seeks require alignment instead of
   silently resetting bitPos.
2. Bbox accumulator (ctf-parser.ts): fold in int16-truncated deltas, matching
   libeot and the coordinates the glyph actually renders with.
3. Reserved-space errors (stream.ts): *ThroughReserve seeks throw
   EOT_SEEK_PAST_EOS and copyTo throws EOT_OUT_OF_RESERVED_SPACE instead of
   auto-growing; the glyph builder already pre-reserves worst-case space.
4. Missing head (sfnt-builder.ts): dumpContainer throws EotError NoHeadTable
   instead of silently skipping the checksumAdjustment patch.
5. hdmx/VDMX diagnostics (ctf-parser.ts): dropped tables surfaced via a new
   SFNTContainer.droppedTables field and an opt-in onWarn callback threaded
   through decompressMtx options.

Adds OffByteBoundary/OutOfReservedSpace/SeekPastEos error codes and the
ParseCTFOptions type; documents onWarn in the README. Test suite 214 -> 222.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deferred libeot-parity items (cosmetic / by-design divergences)

1 participant