Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused parser fix matches the record format and includes adequate regression coverage.
0 open findings
What changed in this PR
Fixes hdmx parsing so padded device records remain correctly aligned.
Changes:
- Skips per-record padding using
sizeDeviceRecord. - Adds an in-memory regression test.
- Documents the fix in the changelog.
| File | Description |
|---|---|
src/tables/hdmx.js |
Consumes record padding. |
test/device_metrics.js |
Tests padded records. |
CHANGELOG.md |
Records the fix. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each
hdmxdevice record is padded tosizeDeviceRecordbytes (a multiple of four), but the struct only read2 + numGlyphsbytes per record. WhennumGlyphs + 2is not a multiple of four, every record after the first was read from the wrong offset.With Arial (4651 glyphs, 3 bytes of padding),
font.hdmx.records.map(r => r.pixelSize)gave11, 0, 6, 9, 6, 15, ...instead of11, 12, 13, 15, 16, 17, ....This skips the padding after each record. Spec: https://learn.microsoft.com/typography/opentype/spec/hdmx
None of the fonts in
test/datahas anhdmxtable, so the test builds a small font in memory.npm testpasses and the changed files are Prettier-clean.