Fix #234: EPS files from the reference app open

EPS files the reference app saves (its procsets in the prolog, a binary header with a TIFF
preview) now open as editable art instead of failing with "undefinedresource in Generic". When
their PostScript still can't be read, the palette preview they carry is placed with the usual
warning instead of the file being refused.

Root cause: five interpreter gaps and one preview format. The Generic and Category resource
categories didn't exist, so categories couldn't be made from Generic (now Category holds the
standard categories, defineresource in Category makes new ones, undefineresource is added);
clipsave/cliprestore were unknown (now a clip stack in the graphics state); systemdict's
languagelevel was the operator, not the integer 3; getinterval copied arrays and strings
instead of sharing their storage, so astore into a subarray was lost (arrays and strings are
now views into shared storage, and readstring/readline return the part they fill); and
resourceforall was unknown (now enumerates matching names with * ? \ templates). The preview
is an 8-bit palette TIFF with an alpha sample, which the image crate can't decode: a small
bounds-checked reader handles that layout (either byte order, any strips).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bflatastic
2026-10-07 09:34:27 +07:00
co-authored by Claude Opus 5.5
parent 83faf568b0
commit 64891c1a2e
11 changed files with 634 additions and 151 deletions
+10 -8
View File
@@ -1679,14 +1679,16 @@ PostScript is read instead and the first warning says why.
Other files are run through a small PostScript interpreter (Level 3, first page only): paths, fills and strokes with
their width, caps, joins, miter limit and dashes (a fill and a stroke of the same path become one object), grey, RGB,
CMYK, indexed and spot colours (a Separation ink becomes a spot swatch, painted at its tint), clips (clipping groups),
`gsave`/`grestore`, `save`/`restore`, transforms, procedures with `bind def`, loops and dictionaries, axial and radial
shadings and shading patterns (gradients), images and image masks (data in the file through ASCII85, hex, run-length,
Flate, LZW or DCT filters, or from procedures), and type as point type in the font the file names (embedded font
programs are skipped). The artboard is the `%%HiResBoundingBox` (else `%%BoundingBox`; a letter page without one).
A program the interpreter can't run (an operator it doesn't know, an error, a runaway loop) or that draws nothing comes
in as its TIFF preview with a warning; without a preview, the art drawn up to the error is kept with a warning, and a
file with none is refused with a message saying why.
CMYK, indexed and spot colours (a Separation ink becomes a spot swatch, painted at its tint), clips (clipping groups;
`clipsave`/`cliprestore`), `gsave`/`grestore`, `save`/`restore`, transforms, procedures with `bind def`, loops,
dictionaries, arrays and strings whose intervals share storage, resources (categories made from `Generic`,
`resourceforall`), axial and radial shadings and shading patterns (gradients), images and image masks (data in the
file through ASCII85, hex, run-length, Flate, LZW or DCT filters, or from procedures), and type as point type in the
font the file names (embedded font programs are skipped). The artboard is the `%%HiResBoundingBox` (else
`%%BoundingBox`; a letter page without one). A program the interpreter can't run (an operator it doesn't know, an
error, a runaway loop) or that draws nothing comes in as its TIFF preview (palette previews with an alpha channel too)
with a warning; without a preview, the art drawn up to the error is kept with a warning, and a file with none is
refused with a message saying why.
```json
{"name":"run_command","arguments":{"command":"document.open","params":{"path":"/tmp/logo.eps"}}}