Files
vectorcraft/crates
jmvergesandClaude Opus 5.5 400b4c96f9 pdf: page widths: bound the work of looking up a font's characters
In the pinned CMap, each lookup of a code in a `bfrange` copies the
range's whole destination and decodes it, so a `ToUnicode` map under the
256 KB limit with one long destination, shared by many fonts whose `W`
names every CID, cost millions of long copies. `MAX_CHARS` didn't stop
it, since such lookups give no character.

- A `ToUnicode` map holding a string longer than 128 bytes decoded
  (`MAX_DESTINATION`: hex, literal, or any ASCII85 string, whose `z`
  stands for four bytes), or written as a binary CMap, is left unread,
  as one past the size limits is: its fonts give no widths. The scan
  steps over dictionaries (`<<`) and comments as the CMap reader does.
- A composite font looks up at most `MAX_LOOKUPS` (16,384) of its codes
  with a width, in `W` order, and keeps what it found among them.

Tests `a_to_unicode_map_with_a_long_destination_is_left_unread` and
`codes_past_the_most_looked_up_are_left`, each failing without its part.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 07:42:44 +00:00
..
…