Skip to content

Fix #861: open .ai files whose non-native art has ASCII85 lines starting with %_ - #854

Merged
bflatastic merged 1 commit into
storytold:mainfrom
rschuerer:fix/ai-non-native-art
Oct 10, 2026
Merged

bflatastic merged 1 commit into
storytold:mainfrom
rschuerer:fix/ai-non-native-art

Conversation

@rschuerer

@rschuerer rschuerer commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #861.

A .ai saved by Illustrator 28 without PDF compatibility wouldn't open: "this file was saved without PDF compatibility, and its editing data can't be read (it ends inside a layer)".

Commit 1: open the file

Its layer starts with a /ForeignObject (non-native art: the content of a placed PDF), whose /Data entry is that PDF as ASCII85 in % comment lines. ASCII85 includes _, so about one line in 85 starts with %_, which the lexer reads as hidden tokens; a ( in such a line opened a string that swallowed the dictionary's ;, the rest of the art and the layer's LB. The reader now reads that data as a whole, up to its ~>, as it already did for a /Binary dictionary's ASCII85.

Commit 2: draw the non-native art

The letterhead's main graphic, a fan of swooshes, is exactly that object: a radial gradient in a 3-point PDF, scaled 271 times and clipped by the swoosh paths. Leaving it out opened a page without its graphic.

The reader now decodes the PDF, has the PDF importer read it, and fits its art to the object's box as a group named "Non-native art". The box is /Bounds measured from /Origin with y down, then /RTransform; on both objects of that file it lands exactly on the clipping paths around them. The PDF's content keeps its own y-up coordinates, so it is flipped into the box (verified against the original: the gradient fades from the apex at the top right). Ids are the document's, the PDF's swatches stay unlinked, its images join by content key. A PDF that can't be read is left out with a note.

The EPS crate now uses the PDF crate, both layer 3; xtask layers allows it like render and metafile.

Tests: a data line starting with %_( that isn't a PDF (opens, note), and a real tiny PDF with two squares fitted to the box, checking placement, orientation, colours and ids. docs/mcp.md updated. cargo xtask ci passes.

Not in this PR: showing a failed open's error in the window (noted in #861).

🤖 Generated with Claude Code

https://claude.ai/code/session_017ZwZjADUZP4VzvrFGpiZch

@bflatastic

Copy link
Copy Markdown
Member

Thanks again, @rschuerer! This is a neat find: an ASCII85 line that happens to start with %_ turning into hidden tokens. Skipping to ~> after /Data , the same way as /Binary is the right fix, and leaving the non-native art out with a note is honest. It's in my CI queue now; I'll merge it once the full cargo xtask ci passes here.

@rschuerer rschuerer changed the title Open .ai files whose non-native art has ASCII85 lines starting with %_ Fix #861: open .ai files whose non-native art has ASCII85 lines starting with %_ Oct 10, 2026
A letterhead saved by Illustrator 28 without PDF compatibility wouldn't
open: "its editing data can't be read (it ends inside a layer)". Its
layer starts with a /ForeignObject (non-native art: the content of a
placed PDF), whose /Data entry is the PDF as ASCII85 in comment lines.
ASCII85 includes `_`, so about one line in 85 starts with `%_`, which
the lexer reads as hidden tokens; a `(` in such a line opened a string
that swallowed the dictionary's end, the rest of the art and the
layer's LB.

The reader now skips to the data's `~>` after `/Data ,` in a
/ForeignObject, as it already did for a /Binary dictionary's ASCII85,
and leaves the non-native art out with a note (nothing draws its PDF
from the editing data yet).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ZwZjADUZP4VzvrFGpiZch
@bflatastic
bflatastic force-pushed the fix/ai-non-native-art branch from 424bf6c to f2ba41d Compare October 10, 2026 01:25
@bflatastic
bflatastic merged commit ef574b6 into storytold:main Oct 10, 2026
1 check passed
@bflatastic

Copy link
Copy Markdown
Member

Merged, thanks @rschuerer! Tracking a file that "ends inside a layer" down to an ASCII85 line that happens to start with %_ is a lovely piece of detective work. Skipping to ~> after a /ForeignObject's /Data ,, the same way the reader already does for /Binary, fixes it at the root, and leaving the non-native art out with a warning (rather than silently) is the honest choice until we can draw it. The test pins exactly the bad case, a ( inside a %_ line.

I rebased it onto current main (only docs/mcp.md had moved, no conflict); the full cargo xtask ci passed on that head, all 7 steps.

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.

BUG Some .ai files saved without PDF compatibility don't open, and the app shows no error

2 participants