Skip to content

capi: collect nominal cmap Unicode coverage - #526

Merged
behdad merged 3 commits into
mainfrom
capi/collect-unicodes
Oct 9, 2026
Merged

behdad merged 3 commits into
mainfrom
capi/collect-unicodes

Conversation

@behdad

@behdad behdad commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Chromium's optional subset fuzzer calls hb_face_collect_unicodes to populate its input Unicode set. Add the corresponding hr_face_collect_unicodes entry point and HarfBuzz compatibility alias, using the selected cmap subtable's raw character codes and preserving existing set entries.

Format 0 iteration is implemented upstream in Fontations #2265, and coverage for that format depends on a release containing that fix. Insert format-13 constant-glyph ranges directly, bounded by valid glyph IDs and the Unicode range, and exclude format-4's sentinel. Symbol/Mac Roman lookup remapping and variation selectors do not change the collected character codes.

Validation:

  • 152 C API tests, workspace Clippy (all features/targets), and Rust 1.85 check pass.
  • With published read-fonts 0.45: 491 coverage sets match HarfBuzz 14.6.0, with the two format-0 faces excluded; two format-13 sets are independently verified.
  • Corpus comparison with Fontations #2265 patched in: 493 coverage sets match HarfBuzz 14.6.0; two format-13 faces independently match their complete constant-glyph ranges. HarfBuzz incorrectly clips these ranges as though glyph IDs incremented within each range; this implementation keeps the full coverage.
  • GCC/Clang C99 linkage and C++17 header checks pass.

Adds a reusable ctypes comparison script and regression tests for additive collection, empty/null handles, inverted sets, and a format-13 last-resort font.

Closes the optional subset-fuzzer API gap in #520; Chromium build integration is tracked separately there.

@dfrg dfrg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generic Fontations iterator does not implement format 0.

Thanks, seems like this should be fixed in fontations.

Link the temporary read-fonts 0.45 workaround to Fontations #2265. Keep coverage working with the released dependency until the upstream iterator support is published.
@behdad

behdad commented Oct 9, 2026 •

Copy link
Copy Markdown
Member Author

Implemented format 0 iteration upstream in Fontations #2265, adding Cmap0::iter() and the generic subtable iterator dispatch. The upstream regression checks all 256 stored character codes, including glyph zero and the final entry.

Removed the format 0 fallback and its coverage cases from this PR. Format 0 now follows the generic iterator, so collecting its coverage depends on a read-fonts release containing the upstream fix.

Validation: 152 C API tests pass with the published dependency. With the upstream fix patched in, the full corpus has 493 matching coverage sets and two independently verified format-13 sets.

Remove the format 0 fallback and its C API coverage cases. The generic iterator will cover that format once read-fonts includes Fontations #2265.
@behdad
behdad merged commit e125237 into main Oct 9, 2026
3 checks passed
@behdad
behdad deleted the capi/collect-unicodes branch October 9, 2026 20:19
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