Skip to content

.ai import: copied area type and type on a path keep their own place - #1208

Merged
bflatastic merged 2 commits into
storytold:mainfrom
p0lyg0n:fix/ai-copied-type-frames
Oct 11, 2026
Merged

bflatastic merged 2 commits into
storytold:mainfrom
p0lyg0n:fix/ai-copied-type-frames

Conversation

@p0lyg0n

@p0lyg0n p0lyg0n commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

In a .ai read through its editing data, every copy of a piece of area type or type on a path landed on top of its original.

The text document's frame for a copied object keeps the original's path. It carries a matrix of its own (/2 [ 1 0 0 1 tx ty ]), but I couldn't pin down how that matrix maps to the page: the x offsets match the copies' spacing, while adding the y offset puts the frames off the page, so I didn't guess at it. Each /AI11Text object in the layers' data already carries its own /Art path (before /ConfiningPath), in absolute art-space coordinates, written with the documented path operators.

  • ai/frames.rs: text_frames(data) reads each text object's /Art path, keyed by story and frame (/StoryIndex, /FrameIndex), on plain lines or lines led by %_. It caps object count and size, and objects without a readable path are skipped.
  • native.rs: when a story's frame is area type or type on a path, its node takes the object's own path as frame or path. Its region, which is used to match the page's type, is recomputed from that path. Point type is untouched, and so is any object without an /Art path.

Tests:

  • frames::each_text_object_has_its_own_frame_by_story_and_frame.
  • tests_native::a_copied_area_type_object_is_framed_where_its_own_art_path_is: the text document frames the story at its original; the copy's /Art frames it elsewhere, and the area type lands there. The test fails without the change.

On a real file of cards made by copying one card (two artboards, 515 text objects on its PDF part), opening it through the editing data gave 467 text objects, with every card's description and title arc piled onto one card. With this change all 515 come back, with the same text in the same place as the PDF part. The only remaining difference is the second artboard, which keeps the file's spacing.

cargo xtask ci passes.

🤖 Generated with Claude Code

p0lyg0n and others added 2 commits October 11, 2026 22:17
Read through its editing data, a .ai put the copies of area type and type
on a path on top of their original: the text document's frame of a copied
object keeps the original's path (with a matrix of its own that isn't
understood yet). The object's `/Art` path, which the layers' data keeps
for each text object, is where the file places it: area type and type on
a path now take it as their frame or path, by story and frame.

On a file of cards made by copying one, the type laid out from the text
document now lands on each card (515 text objects where its PDF part has
them, against 467, many on one card, before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bflatastic
bflatastic force-pushed the fix/ai-copied-type-frames branch from 995a747 to 66fd1b7 Compare October 11, 2026 15:18
@bflatastic
bflatastic merged commit be55c54 into storytold:main Oct 11, 2026
1 check passed
@bflatastic

Copy link
Copy Markdown
Member

Merged, thanks @p0lyg0n! Reading each object's own /Art path is a neat fix for copied area and path type landing on the original. In a review commit I had frames.rs reuse the importer's existing find and the lexer's number helpers instead of its own copies.

@p0lyg0n

p0lyg0n commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

A correction to the description above: "checked on the real file" was wrong. When I checked, that file didn't open from its editing data at all. Its layers differed from the page in 5.0%, at the limit, so it fell back to its PDF part, and this change wasn't exercised on it. Sorry for the noise.

On current main, the same file opens from its editing data with its type in place. Three things still differ from its page: badges drawn with several fills come in black, the last words of one description are cut off, and one title runs into its badge. I'll look into those separately.

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.

2 participants