Files
pdfcraft/crates/edit
910b70bb5f M7: keep embedded CMap ranges compact instead of truncating expansion (#837)
* M7: keep embedded CMap ranges compact instead of truncating expansion

A ToUnicode CMap's sequential bfrange used to expand into one HashMap
entry per code, and the parser stopped at 2^20 expanded codes. A valid
CMap with more codes than that lost every mapping past the cap.

Each sequential range is now one record. Codes below 65 536 find their
covering record in a table, higher codes by binary search over a cover
index; the later declaration wins where ranges and explicit entries
overlap. Explicit entries keep their strings. The budget counts an
explicit entry as one and a range as two, since a range covers at least
two codes, so every CMap with at most 2^20 codes is kept whole. encode
finds the lowest code per character from the same records.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>

* ToUnicode: size the low-code tables to the codes a font covers

---------

Co-authored-by: Claude Haiku 5.5 <noreply@anthropic.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>
2026-10-10 17:14:24 -04:00
..