Files
vectorcraft/crates/engine/tests
jmvergesandClaude Opus 5.5 546d274e6e .ai import: type takes the installed copy that sets its PDF part's widths
When several installed faces answer to a text document font record's
PostScript name and the record keeps no version (no key 5), type was set in
whichever copy loaded first. Two copies can share the PostScript name, family
and style and differ only in their widths (two releases of one font): the type
then set at other widths than the file's own page, and envelopes of it could
fail their drawn-art check. #6983 left this case out, as only the page's
widths tell such copies apart.

- `Opened::page_widths` (crates/pdf/src/page_widths.rs) reads the widths the
  pages give the characters of each font they set type in, from the font
  dictionaries alone and without importing any page: a simple font's
  `Widths` from `FirstChar`, a composite font's descendant's `W` under an
  `Identity-H`/`Identity-V` CMap, each code's character from the font's
  `ToUnicode` map or, for a simple font without one whose `Encoding` is
  `WinAnsiEncoding`, from that encoding (ISO 32000-1 9.6.2, 9.7.4.3, 9.10.3,
  Annex D.2), by `BaseFont` without its subset tag. Zero widths (codes a
  subset doesn't use) are left out; subsets that give a character two widths
  give none.
- Its cost is bounded by the file: each resource dictionary is walked once,
  however many pages and forms share it, within 65,536 entries for the whole
  file, 256 fonts and 4,096 forms; a width array that fonts share by
  reference is read once, and none past 4 MB of them; a `ToUnicode` map is
  parsed once for all the fonts that name it, and one over 256 KB decoded,
  or past 4 MB of maps in all (each charged at most what could be decoded
  of it), is left unread. `cid_ranges` reads a `W` list's values as it
  takes them instead of collecting the whole list. A font's widths are
  shared, not copied.
- `postscript_face` (crates/eps/src/import/text.rs) takes, among the faces
  of the record's name, the first that sets those characters (the first 512
  in code-point order) each within 1/1000 em. With no widths, one face, a
  version in the record, or no face that sets them all, the pick is the one
  before. The face found first is checked before any other is loaded, and
  the records of one name and version share their widths and their answer,
  so each font resolves once whatever the number of records.
- The widths reach the text document through `Structure::page_widths` and
  `Texts::with_page_widths`; the engine reads them once per open and passes
  them to `ai_layers_alone`, `AiLayers::with_page_widths` and `ai_alone_with`
  when it reads a `.ai`'s editing copy beside a PDF part (not for a
  placeholder page).
- `without_subset_tag` replaces two copies of the subset-tag strip in the PDF
  import, and `replacement` (a `ToUnicode` value that names no character) is
  shared with it.
- A fuzz target feeds hostile font dictionaries, `ToUnicode` maps and forms
  that draw themselves to the reader.

Measured on 224 users' files (used locally, never committed): 3 font records
in 3 files change copy, each now within 0.5/1000 em of its page; those 3
renders, and no others, change, all closer to the file's own page; envelopes
of type that open live go from 185 to 186, none fewer in any file; no file
opens another way.

Refs #6983

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