Skip to content

.ai import: the document's graphic styles open in the panel with their objects linked - #5155

Merged
bflatastic merged 3 commits into
storytold:mainfrom
dotCooCoo:fix/ai-os12
Nov 2, 2026
Merged

bflatastic merged 3 commits into
storytold:mainfrom
dotCooCoo:fix/ai-os12

Conversation

@dotCooCoo

@dotCooCoo dotCooCoo commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Part of #3349.

A document keeps its own graphic styles ("Styles that are saved with the active document appear in the panel when that
document is open and active.",
Graphic Styles panel overview),
and objects stay linked to the style they use until the link is broken ("To break the link to a graphic style, select
the object, and then select Break Link to Graphic Style.",
Apply graphic styles).
Every object also has an unnamed style of its own that the panel doesn't show ("Converts a named style, which is shown
in the Graphic Styles palette, to an anonymous style, which is not.",
AIArtStyleSuite reference). Today a .ai opened from its
editing data always shows VectorCraft's four default graphic styles, and no object is linked.

With this change the editing-data reader reads the style list (%AI9_BeginArtStyleList, one PostScript string per
style in the panel's order):

  • Each listed style whose appearance the reader builds (solid fills and strokes with their own transparency, and the
    effects it already reads) comes in, in the list's order, in place of the default graphic styles. It keeps the
    opacity, blend mode, isolation and knockout of its blend filter. A name listed twice, an empty name and a name with no
    definition are left out. Styles that paint with a gradient or a pattern are left out for now. Without a list, or with
    none of its styles read, the defaults stay.
  • An object read as itself with a listed style (1 (name) XW) is linked to that graphic style when it has the style's
    appearance and transparency. This covers paths, groups and type made from the text document (and page type that
    replaces a styled text object with the same appearance). A 1 that names a style the list doesn't have is the
    object's own appearance: it keeps that appearance and links nothing. 6, 7 and 9 markers are never links.
  • Styles are scaled with the art: editing data in the units of a UserUnit page, and Large Canvas copies. In a Large
    Canvas copy, an object read with an art style now also gets its strokes and effects at the page's size; before, they
    stayed at the copy's 1/N scale.

No public source describes the style list or the XW codes; the rules above are VectorCraft's reader behavior.

How it was tested

New tests build synthetic editing data from scratch:

  • crates/eps/src/import/ai/tests.rs: listed_styles_replace_the_default_graphic_styles_and_link_their_objects,
    only_listed_styles_that_are_defined_and_read_come_in_once, a_style_the_list_does_not_have_is_no_link,
    a_group_with_a_listed_style_is_linked, an_object_whose_transparency_differs_from_its_listed_style_is_not_linked,
    a_listed_style_keeps_its_transparency_and_links_objects_that_have_it,
    a_path_with_a_listed_style_that_fills_below_the_contents_is_linked, a_style_name_outside_ascii_links_its_objects
    and without_a_style_list_the_default_graphic_styles_stay.
  • crates/eps/src/import/ai/style/tests.rs: a_style_list_keeps_its_strings_in_order (escapes, nesting, unended
    strings, the name and entry caps).
  • crates/eps/src/import/tests_native.rs: type_with_a_listed_art_style_is_linked_to_its_graphic_style,
    graphic_styles_in_the_units_of_a_user_unit_page_come_in_at_the_pages_size and
    a_large_canvas_eps_keeps_its_graphic_styles_at_the_pages_size.
  • crates/engine/src/cmd/fileio/tests_aiimport.rs: an_ai_file_opens_with_the_graphic_styles_of_its_style_list.
  • crates/engine/tests/import_fuzz.rs: ai_style_lists_and_style_links_never_panic (lists of any entries, with or
    without their end, and XW with any code and name), and style-list and XW tokens added to arb_ai_token.

Each new test, except the fuzz test and without_a_style_list_the_default_graphic_styles_stay, fails without its part
of the change.

Commands run on 5b9b282a8b, based on main at 77274ac5ff:

  • cargo fmt --all -- --check
  • cargo clippy -p vectorcraft-eps -p vectorcraft-engine --all-targets -- -D warnings
  • cargo test -p vectorcraft-eps: 554 passed
  • cargo test -p vectorcraft-engine --lib aiimport: 39 passed
  • cargo xtask brands, layers and assets

The branch merges cleanly with main at 5628de96f8. It changes lines next to #5046, #5082, #5102, #5115, #5117, #5142
and #5144 (reader fields, finish, slots.rs, the style tests, the fuzz tokens and the docs list); whichever merges
later needs those lines merged.

cargo xtask ci passed in this pull request's CI run on ebe473bf8b: https://github.com/storytold/vectorcraft/actions/runs/41359256925/job/125005884484

Checklist

  • cargo xtask ci passes (fmt, clippy, tests, assets, brands, layers, wasm).
  • 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.

Summary by CodeRabbit

  • New Features
    • Illustrator imports now restore listed graphic styles in their original order and link matching objects to those styles.
    • Imported styles preserve supported appearance and transparency settings; objects using unsupported or unlisted styles retain their drawn appearance.
    • Graphic-style strokes and effects scale appropriately when importing scaled documents.
  • Bug Fixes
    • Text replacements can retain matching graphic-style links during import.

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 5628de9 and 5b9b282.

Files selected for processing: 13
  • crates/engine/src/cmd/fileio/tests_aiimport.rs
  • crates/engine/tests/import_fuzz.rs
  • crates/eps/src/import/ai/read.rs
  • crates/eps/src/import/ai/read/directives.rs
  • crates/eps/src/import/ai/read/document.rs
  • crates/eps/src/import/ai/read/ops.rs
  • crates/eps/src/import/ai/style.rs
  • crates/eps/src/import/ai/style/tests.rs
  • crates/eps/src/import/ai/tests.rs
  • crates/eps/src/import/native/build.rs
  • crates/eps/src/import/native/slots.rs
  • crates/eps/src/import/tests_native.rs
  • docs/target-app-parity.md

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

Walkthrough

The .ai importer now reads listed graphic styles, creates them in list order, and links matching objects when their appearance and transparency match. Native import scales style appearances and can preserve style links on qualifying replacement text.

Changes: Illustrator Graphic Style Import

Layer / File(s) Summary
Parse style lists and transparency
crates/eps/src/import/ai/read.rs, crates/eps/src/import/ai/read/directives.rs, crates/eps/src/import/ai/style.rs, crates/eps/src/import/ai/style/tests.rs
The reader stores style-list names in order. The parser accepts bounded, closed strings and records transparency attributes, including blend mode, isolation, and knockout.
Convert applied styles and record links
crates/eps/src/import/ai/read/ops.rs
The importer converts supported plain styles into appearances, scales strokes and effects where applicable, and records object-to-style names.
Create document styles and link objects
crates/eps/src/import/ai/read/document.rs, crates/eps/src/import/ai/tests.rs, crates/engine/src/cmd/fileio/tests_aiimport.rs, crates/engine/tests/import_fuzz.rs, docs/target-app-parity.md
Finalization creates readable styles in list order and links nodes when their appearance and transparency match. Tests cover ordering, filtering, name decoding, transparency, and malformed inputs. The parity documentation records the import behavior.
Scale styles and preserve links in native import
crates/eps/src/import/native/build.rs, crates/eps/src/import/native/slots.rs, crates/eps/src/import/tests_native.rs
Native import scales graphic-style strokes and effects when styles were read. Qualifying text replacements retain style links, with tests covering scaling and text-link behavior.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Reader
  participant art_style_list
  participant graphic_styles
  participant Document
  Reader->>art_style_list: Parse the Art Style List section
  art_style_list-->>Reader: Return ordered style names
  Reader->>graphic_styles: Resolve listed names against style definitions
  graphic_styles-->>Document: Provide readable styles in list order
  Document->>Document: Link nodes with matching appearance and transparency
Loading

Suggested reviewers: aiongg, bflatastic

Merge Risk: Low · previous review 5b9b2

Importing an Illustrator file with an unterminated graphic-style name can fail rather than retain the default styles. This is a bounded risk that can be addressed as a follow-up.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title names the main change: .ai import now opens the document's graphic styles in the panel, and objects are linked to them. The diff reads the %AI9_BeginArtStyleList style list, replaces the def…
Docstring Coverage Passed Docstring coverage is 81.25% 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 pull request description includes the required What and why, How it was tested, and Checklist sections. It explains the behavior, scope, implementation limits, tests, commands, CI result, and chec…
Full details: Title check

Explanation

The title names the main change: .ai import now opens the document's graphic styles in the panel, and objects are linked to them. The diff reads the %AI9_BeginArtStyleList style list, replaces the default graphic styles with listed styles, and links objects that use a listed style. The title is concise and specific. It does not mention the gradient/pattern exclusion or the scaling changes, which is acceptable.

Full details: Docstring Coverage

Explanation

Docstring coverage is 81.25% 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 16 functions across 12 files. (1 skipped: 1 unsupported.)

Full details: Description check

Explanation

The pull request description includes the required What and why, How it was tested, and Checklist sections. It explains the behavior, scope, implementation limits, tests, commands, CI result, and checklist status. The description is complete and relevant.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@bflatastic
bflatastic merged commit a181262 into storytold:main Nov 2, 2026
3 checks passed
@bflatastic

Copy link
Copy Markdown
Member

Merged, thanks @dotCooCoo! It went in with this round's batch after a full CI run and a live check. The scaled-page caller of scale_document now passes the styles flag, and the Shadow style in the tests writes every Drop Shadow setting, as #5140's strict reader needs.

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