Skip to content

.ai import: envelopes of type open live where they draw as their drawn art (#3179) - #6421

Merged
bflatastic merged 6 commits into
storytold:mainfrom
jmverges:fix/3179-live-type-envelopes
Nov 10, 2026
Merged

bflatastic merged 6 commits into
storytold:mainfrom
jmverges:fix/3179-live-type-envelopes

Conversation

@jmverges

@jmverges jmverges commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Part of #3179. Follows #6383 (the import note for type in an envelope), which has merged.

An envelope whose contents hold type (a warp, a mesh or a top object around type) kept its drawn art in a .ai, with the type hidden, because the type is laid out from the text document only after the layers are read, so the envelope couldn't be built when its XP closed it.

Now such an envelope waits for the type, the way warped type already does. Once its text slots hold their type, the envelope is built from that type and drawn by VectorCraft's own envelope rule. Where that draws as the drawn art the file saves (same check and same budget as other envelopes, seen on white and on black since #6413), it takes the drawn art's place: the type is visible and editable in Edit Contents, and the hidden copy goes away.

Elsewhere it keeps its drawn art and hidden type, with the #6383 note. That covers type in a font that isn't installed, a slot without type of its own (threaded, bound to a text or a visibility variable, a wrap object, type a look draws), an envelope in a symbol's or a pattern's art, an envelope that doesn't read, no check left, or one that draws differently.

The strict choice: typed envelopes go through the page comparison too

A live envelope made while reading (end_envelope) is held to the page: Structure::envelopes_drawn makes nothing_waits_on_page false, so the layers are compared with the PDF part. Where they don't draw as it, the drawn art is put back (drawn_or_trusted). Typed envelopes now follow the same rules:

  • With a page, each live envelope of type joins envelopes_drawn with its hidden type and drawn art. When the layers don't draw as the page, both are put back, as for other envelopes.
  • A .ai whose layers would otherwise open alone (ai_layers_alone, PDF part not imported) waits on the PDF part when an envelope of type is pending, so one can only open live after the page comparison.
  • If no envelope of type opens live that way, or the layers don't draw as the page even with the drawn art put back, the file opens from its layers alone, as before (the envelopes keep their drawn art). Without that fallback, the plain "do as envelopes_drawn does" version moved 16 of our files from their layers to their PDF part, because their layers had never been compared with the page before. That's a regression nobody asked for.
  • Layers built with no page at all (build_without_page, build_on_page) leave envelopes of type their drawn art (WarpedType::compared).
  • The page comparison weighs a live envelope of type as the art it draws. It used to count the box of the text object in the envelope's contents as type, which it holds to less (type laid out again from the file's text), so most of what the envelope draws went unweighed: one opened live where the page draws other art there, with only a note that the type differs.
  • Layers used though they don't draw as the page leave envelopes of type their drawn art and hidden type, with the note: with the editing data trusted (trust), and when the objects that differ come in as the page's art (keep_differing). A .ai whose layers would open alone then opens alone, as before.

If maintainers would rather rely on each envelope's own check against its drawn art and skip the page comparison for typed envelopes, the relaxation is small. Remove the has_envelopes() early return in ai_layers_alone, the one warped_type.compared(...) line in build_from and the two type_drawn calls (the trust branch of drawn_or_trusted, and before keep_differing), and the page-comparison conditions are gone. The comparison weighing a live envelope as art stays either way. The per-envelope check against the drawn art stays either way. I measured that variant too: it gives the same 74 live envelopes on our files, so in this sample strictness costs no live envelopes, only importing the PDF part for files that carry type envelopes. Typed envelopes would still be put back by envelopes_drawn when a page is there, so a full relaxation also needs that path adjusted.

Known limits (found in review, not changed here)

  • Objects in a live envelope of type's contents don't keep their graphic style link (styles are linked before these envelopes are built).
  • A file with envelopes of type that would open alone now imports its PDF part first; if that import fails, it opens through the "PDF part couldn't be read" path rather than alone.
  • A binding to the type in an envelope isn't carried into the live envelope; such envelopes keep their drawn art.

How it was tested

  • tests_native::an_envelope_of_type_that_draws_as_its_drawn_art_opens_live, an_envelope_of_type_that_draws_apart_from_its_drawn_art_keeps_it, an_envelope_of_white_type_that_draws_apart_from_its_drawn_art_keeps_it, an_envelope_of_type_waits_on_the_page_of_layers_that_would_open_alone, an_envelope_of_type_that_draws_apart_from_the_page_does_not_open_live, trusted_layers_that_draw_apart_from_the_page_leave_an_envelope_of_type_its_drawn_art, layers_with_objects_that_come_in_as_the_page_art_leave_an_envelope_of_type_its_drawn_art and an_envelope_of_type_bound_to_a_visibility_variable_keeps_its_drawn_art. The last one checks that layers which would open alone wait on the PDF part, open alone with the drawn art when the PDF part differs, and open live when it matches. It fails with either half of the change disabled. All synthetic, written from scratch; the font-dependent ones skip when no font is installed, as before.
  • Every step of cargo xtask ci with Rust 1.99.1 on Linux x86_64, run one by one on this branch rebased on main: fmt, clippy, test, doctests, no-bundled-fonts, pdf-deps, assets, brands, cursors, layers, wasm and i18n-report pass. As in PDF import: image masks open colorized by the color they are painted in (#6313) #6321, one test that fails on my machine whatever the change was skipped: vectorcraft-text's tests::harakat::coloured_harakat_keep_kashida, which picks the Arial installed here.
  • Measured on 224 of our own garment files, used locally (never committed), against main:
    • envelopes of type that open live: 0 → 74 in 6 files (mesh 61 of 75, top object 13 of 29, warp 0 of 99; the rest keep their drawn art for a missing font, a slot without its own type, and so on);
    • read mode (layers vs PDF part): no file changed;
    • rendering: 5 files changed, at most 0.5 % of pixels at 40 ppi, all of them files where envelopes of type opened live; the others render identically;
    • notes, against main (which has .ai import: a note for type in an envelope (part of #3179) #6383): one file loses the type-in-envelope note, and two files whose layers are now compared with the page gain its type notes.

Warps of type never matched their drawn art in these files, so they keep it. A follow-up check found that the content size these files save doesn't explain it: it varies widely against the type's boxes and is often stale, and mapping from it opened none of the 99. In many, the contents sit away from the drawn art; where they line up, VectorCraft's warp still bends differently from the warp grid the file saves. So this PR leaves warps alone.

Checklist

  • cargo xtask ci passes (fmt, clippy, tests, assets, brands, layers, wasm), apart from the one machine-specific vectorcraft-text test above.
  • No panics in shipped code: no unwrap(), expect(), panic!, unreachable!, todo! or
    unimplemented! outside tests, and no unchecked indexing on data from files, parameters or
    messages. Errors are returned as Result and shown to the user
    (why and how).
  • Clean-room: nothing copied from Adobe products or GPL/AGPL code (AGENTS.md).
  • Every new asset has a row in ASSETS.md (none added).

Summary by CodeRabbit

  • New Features
    • Illustrator and EPS imports can keep eligible text inside envelopes editable when its rendered appearance matches the saved artwork and the layers match the page.
    • When the text cannot be opened live, imports preserve the saved artwork and retain the text separately, with a note describing the result.
    • Some imports can fall back to using the artwork without the PDF page.
  • Documentation
    • Updated format-parity notes to describe envelope text import behavior.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

AI/EPS import now supports editable text in eligible envelopes when live rendering matches saved drawn art. Other cases retain drawn art and may report an envelope-type note. Page comparison and layers-only fallback paths account for typed envelopes.

Changes: Typed Envelope Import

Layer / File(s) Summary
Collect typed envelopes
crates/eps/src/import/ai.rs, crates/eps/src/import/ai/envelope.rs, crates/eps/src/import/ai/read.rs, crates/eps/src/import/ai/read/*
The reader tracks typed envelopes, defers eligible envelopes for later layout, and applies typed-specific notes when it cannot defer them. It carries typed-envelope data into the finished structure and remaps its color links.
Settle live envelope text
crates/eps/src/import/ai/envelope.rs, crates/eps/src/import/native/build.rs, crates/eps/src/import/native/compare.rs, crates/eps/src/import/ai/tests.rs
Settlement fills eligible envelope slots with text and compares live rendering with drawn art. It retains drawn art when text, font, read, budget, binding, or rendering conditions prevent live settlement.
Apply comparison and fallback results
crates/eps/src/import/native/build.rs, crates/eps/src/import/native/layers.rs, crates/eps/src/import/tests_native.rs, docs/file-format-parity.md, docs/target-app-parity.md
Comparison and trusted fallback paths restore envelope art when needed. The layers-only path can retry the build without the PDF page. Tests and parity documents cover live and fallback outcomes.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Reader
  participant Structure
  participant NativeBuild
  participant PageComparison
  Reader->>Structure: Attach queued typed envelopes
  NativeBuild->>Structure: Read typed envelope data for layout
  NativeBuild->>PageComparison: Compare imported content with page
  PageComparison->>NativeBuild: Return comparison result
  NativeBuild->>NativeBuild: Keep live type or restore drawn art
Loading

Possibly related issues

  • storytold/vectorcraft issue 6137: The PR changes how live envelope type participates in page comparison, but does not address the reported line-layout causes.
  • storytold/vectorcraft issue 6134: The PR changes how typed envelopes participate in the comparison, but does not add the requested prompt.

Suggested reviewers: dotcoocoo

Merge Risk: Minimal · up to 309d7

No merge-blocking issue is established from the available review evidence.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly summarizes the main change: .ai envelopes containing type can open live when their rendering matches the saved drawn art.
Docstring Coverage Passed Docstring coverage is 82.86% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description includes the required “What and why,” “How it was tested,” and “Checklist” sections. It explains the change, provides detailed test and validation results, and addresses each checklist…
Full details: Docstring Coverage

Explanation

Docstring coverage is 82.86% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 35 functions across 9 files. (1 skipped: 1 unsupported.)

Full details: Description check

Explanation

The description includes the required “What and why,” “How it was tested,” and “Checklist” sections. It explains the change, provides detailed test and validation results, and addresses each checklist item.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

LanguageTool

docs/target-app-parity.md

LanguageTool checks are incomplete because the per-file request limit of 5 was reached. Remaining text was skipped; findings from completed checks are retained.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7967c61 and 309d7e5.

Files selected for processing: 1

  • docs/target-app-parity.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@jmverges
jmverges force-pushed the fix/3179-live-type-envelopes branch from fa0d1a3 to 7967c61 Compare November 10, 2026 17:25
@jmverges
jmverges marked this pull request as ready for review November 10, 2026 17:26
jmverges and others added 6 commits November 10, 2026 17:26
…n art

An envelope whose contents hold type kept its drawn art, with the type
hidden, because the type is laid out from the text document only after
the layers are read. It now waits for that, as warped type does: once
its text slots hold their type, the envelope is made of that type and
drawn by VectorCraft's own rule, and where it draws as the drawn art the
file saves (the same check and budget as other envelopes) it takes the
drawn art's place, with the type visible and editable in Edit Contents.
The hidden copy of the type goes.

As other live envelopes are, it is held to the page: when the layers
with it don't draw as the page, its drawn art and hidden type are put
back. A .ai whose layers would open alone, without its PDF part, now
waits on the PDF part when an envelope of type is in them; where none
opens live, the layers open alone as before. Layers built without a page
leave envelopes of type their drawn art.

Elsewhere it keeps its drawn art and hidden type, with the note: type in
a font that isn't available, a slot without made type (threaded, bound
to a text variable, a wrap object, type a look draws), an envelope that
doesn't read, no check left, or one that draws differently. Envelopes in
a symbol's or a pattern's art keep their drawn art.

Part of storytold#3179.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…it draws

The comparison with the page counts the area of each text object that
shows as type, which it holds to less (type laid out again from the
file's text can sit a little apart from the page's). It took the text
object in a live envelope's contents for such type, at its own unbent
box, so most of what an envelope of type draws went unweighed: one
opened live where the page draws other art there, with only a note
that the type differs. The envelope draws its type bent, as art, and
is now weighed as such, as the drawn art it takes the place of is.

Part of storytold#3179.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ugh they differ from the page

An envelope of type opens live only where the layers with it draw as
the page. Two ways of using layers that don't left it live all the
same: the editing data trusted (they come from it with a note), and
the objects that draw differently coming in as the page's art. In both
the envelope now keeps its drawn art and its type, hidden, with the
note, as where its drawn art is put back. A .ai whose layers would
open alone, without its PDF part, then opens alone again, as it did
before envelopes of type could open live, rather than compared with
the page.

The type put back no longer carries the mark of type made from the
text document in its name.

Part of storytold#3179.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…its drawn art

A variable library binds the text object a slot of the envelope's
contents became, which stays hidden beside the drawn art. Once the
envelope opened live that hidden text object went, and its type in the
envelope has an id of its own, so a visibility binding was dropped and
counted as one that wasn't made. A slot bound to a text variable
already kept the drawn art; one bound to a visibility variable does
too now, with the note, so the binding is kept.

Carrying the binding over to the type in the live envelope would bind
an object inside an envelope's contents, which nothing in the import,
the data sets or the .ai writer is known to handle, so it is left for
later.

Part of storytold#3179.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The file-format revision row for storytold#3179 says that the page check weighs
a live envelope of type as the art it draws, that layers used though
they don't draw as the page leave envelopes of type their drawn art,
and that a slot bound to a visibility variable keeps it too, and lists
the new tests. The parity assessment's evidence says the same, and
the change gets its row and status entry there.

Part of storytold#3179.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e until the drawn art is found

The put-back after a failed page check replaces each live envelope with
its drawn art in one go, which fails as a whole when one envelope lies in
another's art: only the outermost are put back now. A live envelope of
type removes its hidden type only once it has found the drawn art it
replaces. The file format docs lose a revision row left twice by a rebase.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jmverges
jmverges force-pushed the fix/3179-live-type-envelopes branch from 7967c61 to 309d7e5 Compare November 10, 2026 17:33
@bflatastic
bflatastic merged commit 8e5d816 into storytold:main Nov 10, 2026
7 checks passed
@bflatastic

Copy link
Copy Markdown
Member

Merged, thanks @jmverges! It passed its CI checks.

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