Skip to content

fix(cpfont): write maxInkTop into the style entry - #2

Closed
martinqnguyen wants to merge 1 commit into
CrazyCoder:masterfrom
martinqnguyen:fix/write-max-ink-top
Closed

martinqnguyen wants to merge 1 commit into
CrazyCoder:masterfrom
martinqnguyen:fix/write-max-ink-top

Conversation

@martinqnguyen

Copy link
Copy Markdown
Contributor

Each style entry in a .cpfont has 4 reserved bytes after dataOffset, and they are always 0 today. This fills the first 2 with the style's tallest ink above the baseline (int16, from the glyph tops the converter already has). A firmware that places a page's first line from the real ink height can then stop guessing an inset, so tall marks such as Vietnamese double accents are not clipped. tenor/cross, a CrossPoint fork, reads this field. The entry stays 32 bytes and the version stays 4, and a 0 still means "unknown" for files built earlier.

CrossPoint upstream never reads those bytes (SdCardFont::load stops at dataOffset), so its behaviour does not change; the font's content hash differs only because it is computed over the file bytes.

A new test builds a two-style font from a synthetic face and checks each entry's field against the largest glyph top read back from the file. It fails without the fix (0 against 18) and passes with it, and the full suite passes. I also built Geist at size 12 with reading, vietnamese coverage and got 27 for Regular and 28 for Bold, matching the tallest glyph in each style.

The style entry has 4 reserved bytes after dataOffset. Fill the first 2
with the style's tallest ink above the baseline, as a little-endian int16.

CrossPoint never reads those bytes, so its behaviour does not change. A
firmware that places the first line of a page from the tallest ink can now
use the real value instead of a guessed inset, which matters for faces
whose accents rise above the nominal ascender. Files written before this
carry 0 there, which such a firmware reads as "unknown", so old files keep
working.

The entry stays 32 bytes and the format version stays 4.
@CrazyCoder

Copy link
Copy Markdown
Owner

Thank you for this. Your commit is on master as f880e05, with your authorship.

I put the field behind a setting that is off by default, in 89e27e6. CrossPoint does not read these bytes, and writing them changes the content hash of every font built. With the setting off, the bytes stay 0 as before.

To turn it on, add max_ink_top = yes to a family's .conf, or to all.conf for every family. Changing the setting rebuilds the affected sizes. It is described in docs/fonts.md, under "Point sizes and output".

Your test now checks both states. The build stamp has a test for the setting too.

@CrazyCoder CrazyCoder closed this Oct 3, 2026
@martinqnguyen

Copy link
Copy Markdown
Contributor Author

Thanks. Off by default makes sense; we will set max_ink_top = yes in our build.

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.

2 participants