diff --git a/crates/engine/src/cmd/swatchlib.rs b/crates/engine/src/cmd/swatchlib.rs index c120f45038..a2fa4bb0bb 100644 --- a/crates/engine/src/cmd/swatchlib.rs +++ b/crates/engine/src/cmd/swatchlib.rs @@ -49,7 +49,7 @@ pub fn specs() -> Vec { "Add to Swatches", ["Window", "Swatch Libraries"], None, - "{library: id or name, names?: [swatch or colour group names in the library] (default: all of it; a group comes as a colour group, a single swatch ungrouped), apply?: \"fill\"|\"stroke\" (also apply the first one to the selection and the defaults, as paint.setFill / paint.setStroke), focus?: true (with apply: false keeps the active proxy)} copy library swatches into the document as one undo step. A swatch the document already has (same name and paint, or a numbered copy of that name with the same color when the name has another color there) isn't added again; a name taken by another swatch gets a number (\"Clay 1 2\"); a tint or gradient whose global or spot color comes in under a numbered name, or is in the document as such a numbered copy, links to that copy. A pattern swatch brings its pattern, as pasting art painted with it does: the same pattern the document has is used, also when its art links to the document's own color of a name, and a name another pattern or swatch has gets a number; a global or spot color its art links to whose name the document gives another color comes in numbered, and the pattern links to it → {library, added: [names in the document, the colors patterns brought included], existing: [names already there], applied?: name}", + "{library: id or name, names?: [swatch or colour group names in the library] (default: all of it; a group comes as a colour group, a single swatch ungrouped), apply?: \"fill\"|\"stroke\" (also apply the first one to the selection and the defaults, as paint.setFill / paint.setStroke), focus?: true (with apply: false keeps the active proxy)} copy library swatches into the document as one undo step. A swatch the document already has (same name and paint, and for a color the same process, global or spot kind, or a numbered copy of that name with the same color when the name has another color there) isn't added again; a name taken by another swatch gets a number (\"Clay 1 2\"); a tint or gradient whose global or spot color comes in under a numbered name, or is in the document as such a numbered copy, links to that copy; a global or spot color it links to that the document lacks comes in with it. A pattern swatch brings its pattern, as pasting art painted with it does: the same pattern the document has is used, also when its art links to the document's own color of a name, and a name another pattern or swatch has gets a number; a global or spot color its art links to whose name the document gives another color comes in numbered, and the pattern links to it → {library, added: [names in the document, the colors patterns, tints and gradients brought included], existing: [names already there], applied?: name}", has_doc, add ), @@ -1151,20 +1151,31 @@ fn add(s: &mut Session, p: &Value) -> Result { // alone, as adding that swatch finds it under its own name. Paints are compared with their // colors linked as `links` says ([`relinked`]). let same_kind = |x: &Swatch, w: &Swatch| x.global == w.global && x.spot == w.spot; + // A color is the same swatch only as the same kind: a library global color is not the + // document's process color of the same name and paint, which a tint cannot link to. + let same_color_kind = |x: &Swatch, w: &Swatch| w.paint.color().is_none() || same_kind(x, w); let numbered = |w: &Swatch, paint: &Paint, links: &HashMap| { let c = copies.get(w.name.as_str())?; - let own = |x: &Swatch| lib_by_name.get(x.name.as_str()).is_some_and(|l| relinked(&l.paint, links) == x.paint); + let own = |x: &Swatch| lib_by_name.get(x.name.as_str()).is_some_and(|l| relinked(&l.paint, links) == x.paint && same_color_kind(x, l)); let found = c.iter().find(|x| !own(x) && x.paint == *paint && same_kind(x, w)); found.map(|x| x.name.clone()) }; let unlinked = HashMap::new(); + // Whether a library global or spot color that paint `p` links to has no place in `links` + // while the document gives its name another swatch, which such a link would find instead. + let misplaced = |p: &Paint, links: &HashMap| { + linked_names(p) + .into_iter() + .any(|n| !links.contains_key(n) && by_name.contains_key(n) && lib_by_name.get(n).is_some_and(|b| b.global || b.spot)) + }; // `paint` is `w`'s paint with the colors it links to as `links` has them in the document. let there = |w: &Swatch, paint: &Paint, links: &HashMap| match (&w.paint, &patterns) { (Paint::Pattern { pattern, .. }, Some(src)) => { patternlib::present_pattern(d, src, pattern).and_then(|target| library_pattern_swatch(d, w, &target)) } + _ if misplaced(&w.paint, links) => None, _ => match by_name.get(w.name.as_str()) { - Some(x) if x.paint == *paint => Some(w.name.clone()), + Some(x) if x.paint == *paint && same_color_kind(x, w) => Some(w.name.clone()), Some(_) => numbered(w, paint, links), None if group_names.contains(w.name.as_str()) => numbered(w, paint, links), None => (w.name == REGISTRATION && d.swatch(&w.name).is_some_and(|x| x.paint == *paint)).then(|| w.name.clone()), @@ -1324,14 +1335,21 @@ fn add(s: &mut Session, p: &Value) -> Result { // A color a pattern added earlier in this call brought with its art is that // swatch when it shows the library swatch's color: it moves to the library // swatch's place, when its colors link where the library swatch's do: to the - // names `links` gives them, and not elsewhere for a color this call has yet to - // add. + // names `links` gives them, not elsewhere for a color this call has yet to add, + // and otherwise to a color of the library color's paint and process, global or spot kind, + // or under the same name when the library has no such swatch (Registration). let fits = |x: &Paint| { let (ours, theirs) = (linked_names(&w.paint), linked_names(x)); ours.len() == theirs.len() && ours.iter().zip(&theirs).all(|(l, t)| match links.get(*l) { Some(to) => to == t, - None => !picked_names.contains(l), + None => { + !picked_names.contains(l) + && match lib_by_name.get(*l) { + Some(b) => d.swatch(t).is_some_and(|x| x.paint == b.paint && same_kind(x, b)), + None => l == t, + } + } }) }; let same = |to: &str| { @@ -1382,6 +1400,26 @@ fn add(s: &mut Session, p: &Value) -> Result { } out.push((w.name.clone(), name)); } + // A library global or spot color that a tint or gradient added here links to, which the + // document does not have and nothing in this call brought, comes in with it, as pasting + // art painted with the tint brings its color. It is listed with the colors patterns + // brought. + let mut wanted: Vec<&str> = vec![]; + let mut seen: HashSet<&str> = HashSet::new(); + for (_, w) in &pending { + for n in linked_names(&w.paint) { + if n != REGISTRATION && !links.contains_key(n) && seen.insert(n) { + wanted.push(n); + } + } + } + for n in wanted { + let Some(b) = lib_by_name.get(n).filter(|b| b.global || b.spot) else { continue }; + let name = free_copy_in(&mut taken, &b.name, |x| lib_by_name.contains_key(x)); + d.swatches.push(Swatch { name: name.clone(), ..(*b).clone() }); + links.insert(n.to_string(), name.clone()); + brought.push((n.to_string(), name)); + } relink_in(d, &pending, &links); Ok((out, reused, brought)) })?; diff --git a/crates/engine/src/tests/swatchlib.rs b/crates/engine/src/tests/swatchlib.rs index 875d9b5e28..9315eadb06 100644 --- a/crates/engine/src/tests/swatchlib.rs +++ b/crates/engine/src/tests/swatchlib.rs @@ -603,7 +603,15 @@ fn apply_paints_with_the_picked_color_not_one_a_pattern_brought() { run(&mut s, "swatch.new", json!({"name": "Ink", "color": "#0000ff"})); let r = run(&mut s, "swatch.library.add", json!({"library": id, "names": ["Ink", "Tiles"], "apply": "fill"})); assert_eq!(named_after(&s, "Ink"), ["Ink", "Ink 2"], "{r}"); - assert_eq!(r["applied"], "Ink", "{r}"); + // The picked global color is not the process one: it comes in numbered, and the pattern's art + // takes it. + assert_eq!(r["applied"], "Ink 2", "{r}"); + assert!(is_global(&s, "Ink 2", "#0000ff"), "{r}"); + // A picked color the document already has is applied, not the pattern added after it. + run(&mut s, "file.new", json!({"width": 100, "height": 100})); + run(&mut s, "swatch.new", json!({"name": "Ink", "color": "#0000ff", "global": true})); + let r = run(&mut s, "swatch.library.add", json!({"library": id, "names": ["Ink", "Tiles"], "apply": "fill"})); + assert_eq!((&r["existing"], &r["applied"]), (&json!(["Ink"]), &json!("Ink")), "{r}"); } /// A numbered copy that another swatch of the same name hides (the document finds the first of a @@ -886,10 +894,11 @@ fn a_library_spot_tint_links_to_the_spot_color_not_a_process_one() { } } -/// A numbered copy that the library's own swatch of that name is (the same paint, whatever its -/// kind) is not also taken for the library color it is numbered after. +/// The library's process color of a numbered name is not the document's global color of that name +/// and paint, so that global color is the numbered copy of the library's global color it is named +/// after. #[test] -fn a_numbered_copy_the_library_has_by_paint_is_not_shared() { +fn a_numbered_process_color_of_the_library_is_not_the_documents_global_copy() { let mut s = session(); run(&mut s, "swatch.new", json!({"name": "Ink", "color": "#0000ff", "global": true})); run(&mut s, "swatch.new", json!({"name": "Ink 2", "color": "#0000ff"})); @@ -899,7 +908,7 @@ fn a_numbered_copy_the_library_has_by_paint_is_not_shared() { run(&mut s, "swatch.new", json!({"name": "Ink", "color": "#ff0000", "global": true})); run(&mut s, "swatch.new", json!({"name": "Ink 2", "color": "#0000ff", "global": true})); let r = run(&mut s, "swatch.library.add", json!({"library": id, "names": ["Ink", "Ink 2"]})); - assert_eq!((&r["added"], &r["existing"]), (&json!(["Ink 3"]), &json!(["Ink 2"])), "{r}"); + assert_eq!((&r["added"], &r["existing"]), (&json!(["Ink 2 2"]), &json!(["Ink 2"])), "{r}"); } /// A library tint added with a pattern whose art took the document's numbered copy of the tint's @@ -948,21 +957,115 @@ fn a_numbered_tint_the_library_has_is_not_shared() { assert_eq!(r["added"].as_array().map(Vec::len), Some(1), "{r}"); } -/// Adding a library color the document has as a process color of the same paint, with its tint, -/// again adds no other copy of the tint. +/// The document's swatch `name` is a global color showing `hex`. +fn is_global(s: &Session, name: &str, hex: &str) -> bool { + doc(s).swatch(name).is_some_and(|w| w.global && w.paint.color().is_some_and(|c| c.to_hex() == hex)) +} + +/// A library inks library (global `Ink` #0000ff and its tint `Ink half`) loaded into `s`, which is +/// then left in a new document whose own `Ink` is the same blue as a process color → the id. +fn tinted_ink_library_and_a_process_ink(s: &mut Session) -> Value { + let id = tinted_ink_library_and_a_red_ink(s); + run(s, "swatch.delete", json!({"names": ["Ink"]})); + run(s, "swatch.new", json!({"name": "Ink", "color": "#0000ff"})); + id +} + +/// A library global color is not the document's process color of the same name and paint: it +/// comes in numbered, its tint links to it, and adding the two again adds nothing. #[test] fn a_library_tint_of_a_color_the_document_has_as_process_is_added_once() { let mut s = session(); - run(&mut s, "swatch.new", json!({"name": "Ink", "color": "#0000ff", "global": true})); + let id = tinted_ink_library_and_a_process_ink(&mut s); + let r = run(&mut s, "swatch.library.add", json!({"library": id, "names": ["Ink", "Ink half"]})); + let base = tint_base(&s, "Ink half").unwrap_or_default(); + assert!(base != "Ink" && is_global(&s, &base, "#0000ff"), "{r}"); + let before = (named_after(&s, "Ink"), named_after(&s, "Ink half")); + let again = run(&mut s, "swatch.library.add", json!({"library": id, "names": ["Ink", "Ink half"]})); + assert_eq!(again["added"], json!([]), "{again}"); + assert_eq!((named_after(&s, "Ink"), named_after(&s, "Ink half")), before, "{r} then {again}"); +} + +/// A library tint added without its global color, in a document whose swatch of the color's name +/// is another color or a process color, brings its color along and links to it, not to the +/// document's swatch; adding the tint again adds nothing. +#[test] +fn a_library_tint_added_alone_brings_its_color_beside_a_namesake() { + for process in [false, true] { + let mut s = session(); + let id = if process { tinted_ink_library_and_a_process_ink(&mut s) } else { tinted_ink_library_and_a_red_ink(&mut s) }; + let r = run(&mut s, "swatch.library.add", json!({"library": id, "names": ["Ink half"]})); + let base = tint_base(&s, "Ink half").unwrap_or_default(); + assert!(base != "Ink" && is_global(&s, &base, "#0000ff"), "process {process}: {r}"); + assert_eq!(r["added"], json!(["Ink half", base]), "process {process}: {r}"); + let again = run(&mut s, "swatch.library.add", json!({"library": id, "names": ["Ink half"]})); + assert_eq!((&again["added"], &again["existing"]), (&json!([]), &json!(["Ink half"])), "process {process}: {again}"); + } +} + +/// A library tint of a spot color is not the document's tint of the same name and paint whose +/// color is a global process color: adding it alone brings the spot color and a tint of it. +#[test] +fn a_library_spot_tint_is_not_the_documents_tint_of_a_process_namesake() { + let mut s = session(); + run(&mut s, "swatch.new", json!({"name": "Ink", "color": "#0000ff", "spot": true})); run(&mut s, "swatch.new", json!({"name": "Ink half", "swatch": "Ink", "tint": 50})); let b64 = run(&mut s, "document.serialize", json!({}))["dataBase64"].as_str().unwrap().to_string(); let id = run(&mut s, "swatch.library.load", json!({"dataBase64": b64, "name": "Inks.vectorcraft"}))["library"].clone(); run(&mut s, "file.new", json!({"width": 100, "height": 100})); - run(&mut s, "swatch.new", json!({"name": "Ink", "color": "#0000ff"})); - let r = run(&mut s, "swatch.library.add", json!({"library": id, "names": ["Ink", "Ink half"]})); - let before = named_after(&s, "Ink half"); - let again = run(&mut s, "swatch.library.add", json!({"library": id, "names": ["Ink", "Ink half"]})); - assert_eq!(named_after(&s, "Ink half"), before, "{r} then {again}"); + run(&mut s, "swatch.new", json!({"name": "Ink", "color": "#0000ff", "global": true})); + run(&mut s, "swatch.new", json!({"name": "Ink half", "swatch": "Ink", "tint": 50})); + let r = run(&mut s, "swatch.library.add", json!({"library": id, "names": ["Ink half"]})); + let tint = r["added"][0].as_str().unwrap_or_default().to_string(); + let base = tint_base(&s, &tint).unwrap_or_default(); + assert!(doc(&s).swatch(&base).is_some_and(|w| w.spot), "{r}"); + let again = run(&mut s, "swatch.library.add", json!({"library": id, "names": ["Ink half"]})); + assert_eq!((&again["added"], &again["existing"]), (&json!([]), &json!([tint])), "{again}"); +} + +/// A tint of a process namesake that a pattern's art brings is not taken for a picked library +/// tint of a spot color. +#[test] +fn a_library_spot_tint_is_not_a_process_tint_a_pattern_brought() { + let mut s = session(); + run(&mut s, "swatch.new", json!({"name": "Ink", "color": "#0000ff", "spot": true})); + run(&mut s, "swatch.new", json!({"name": "Ink half", "swatch": "Ink", "tint": 50})); + let dot = run(&mut s, "shape.rectangle", json!({"x": 0, "y": 0, "width": 6, "height": 6}))["id"].clone(); + run(&mut s, "paint.setFill", json!({"swatch": "Ink half", "ids": [dot]})); + run(&mut s, "paint.setStroke", json!({"none": true, "ids": [dot]})); + run(&mut s, "select.set", json!({"ids": [dot]})); + run(&mut s, "object.pattern.make", json!({"name": "Tiles", "width": 8, "height": 8})); + run(&mut s, "object.pattern.done", json!({})); + let b64 = run(&mut s, "document.serialize", json!({}))["dataBase64"].as_str().unwrap().to_string(); + let id = run(&mut s, "swatch.library.load", json!({"dataBase64": b64, "name": "Tiles.vectorcraft"}))["library"].clone(); + let r = run(&mut s, "shape.rectangle", json!({"x": 0, "y": 0, "width": 40, "height": 40}))["id"].clone(); + run(&mut s, "paint.setFill", json!({"swatch": "Tiles", "ids": [r]})); + run(&mut s, "select.set", json!({"ids": [r]})); + run(&mut s, "edit.copy", json!({})); + run(&mut s, "file.new", json!({"width": 100, "height": 100})); + run(&mut s, "swatch.new", json!({"name": "Ink", "color": "#0000ff", "global": true})); + run(&mut s, "edit.paste", json!({"swatchConflict": "merge"})); + let tints: Vec = doc(&s).swatches_iter().filter(|w| w.name.starts_with("Ink half")).map(|w| w.name.clone()).collect(); + if !tints.is_empty() { + run(&mut s, "swatch.delete", json!({"names": tints})); + } + run(&mut s, "swatch.delete", json!({"names": ["Tiles"]})); + let r = run(&mut s, "swatch.library.add", json!({"library": id, "names": ["Tiles", "Ink half"]})); + let picked = r["added"].as_array().and_then(|a| a.iter().filter_map(|n| n.as_str()).find(|n| n.starts_with("Ink half"))).unwrap_or_default(); + let base = tint_base(&s, picked).unwrap_or_default(); + assert!(doc(&s).swatch(&base).is_some_and(|w| w.spot), "{r}"); +} + +/// A library tint added without its global color to a document that has no swatch of the color's +/// name brings the color along under its own name. +#[test] +fn a_library_tint_added_alone_brings_its_missing_color() { + let mut s = session(); + let id = tinted_ink_library_and_a_red_ink(&mut s); + run(&mut s, "swatch.delete", json!({"names": ["Ink"]})); + let r = run(&mut s, "swatch.library.add", json!({"library": id, "names": ["Ink half"]})); + assert_eq!(tint_base(&s, "Ink half").as_deref(), Some("Ink"), "{r}"); + assert!(is_global(&s, "Ink", "#0000ff"), "{r}"); } /// A library tint added with a pattern the document already has (pasted with Merge, so it brings @@ -1002,8 +1105,8 @@ fn a_library_tint_with_a_pattern_the_document_has_is_added_once() { } } -/// A library gradient whose stops link to a color and to the Registration swatch, picked before a -/// pattern whose art brings the color under a numbered name, is not added a second time. +/// A library gradient whose stops link to a color and to the Registration swatch, picked before or +/// after a pattern whose art brings the color under a numbered name, is not added a second time. #[test] fn a_gradient_with_a_registration_stop_before_its_pattern_is_not_copied() { let mut s = session(); @@ -1018,10 +1121,12 @@ fn a_gradient_with_a_registration_stop_before_its_pattern_is_not_copied() { run(&mut s, "object.pattern.done", json!({})); let b64 = run(&mut s, "document.serialize", json!({}))["dataBase64"].as_str().unwrap().to_string(); let id = run(&mut s, "swatch.library.load", json!({"dataBase64": b64, "name": "Squares.vectorcraft"}))["library"].clone(); - run(&mut s, "file.new", json!({"width": 100, "height": 100})); - run(&mut s, "swatch.new", json!({"name": "Ink", "color": "#ff0000", "global": true})); - let r = run(&mut s, "swatch.library.add", json!({"library": id, "names": ["Fade", "Squares"]})); - assert_eq!(named_after(&s, "Fade"), ["Fade"], "{r}"); + for names in [json!(["Fade", "Squares"]), json!(["Squares", "Fade"])] { + run(&mut s, "file.new", json!({"width": 100, "height": 100})); + run(&mut s, "swatch.new", json!({"name": "Ink", "color": "#ff0000", "global": true})); + let r = run(&mut s, "swatch.library.add", json!({"library": id, "names": names})); + assert_eq!(named_after(&s, "Fade"), ["Fade"], "{names}: {r}"); + } } /// A library tint follows its color when the call picks the color, even when a pattern added diff --git a/docs/mcp.md b/docs/mcp.md index 6eda2bc435..0a31452419 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -5807,8 +5807,10 @@ another color is the document's numbered copy of the same color when it has one, again adds nothing. A pattern the document already holds with its art linked to the document's own color of that name is used as it is. A library tint or gradient whose global or spot color comes in under a numbered name, or is in the document as such a numbered copy, links to that copy, whether the color is picked before or after it, was added -earlier or came with a pattern's art. `added` lists the colors -the pattern's art brings too. A document with +earlier or came with a pattern's art. A library global color is not the document's process color of the same name and +paint: it comes in numbered. A global or spot color that a library tint or gradient links to and the document lacks +comes in with the tint or gradient, under a numbered name when the document gives its name another swatch. `added` +lists the colors the pattern's art, a tint or a gradient brings too. A document with no swatches, and a `.ai`, `.eps` or PostScript file whose swatches are only the default ones, are refused with "`` has no swatches of its own", unless the document has graph designs: it then loads with no swatches. The Swatch Libraries filter of Other Library… lists `.ai`, `.ait` and `.eps` (`.epsf`) files as well as the library files. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 388bc655d1..8a406b82b8 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -2237,7 +2237,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur A symbol instance written as its art, and a blend, mesh, repeat, placed document, intertwine or envelope written as a group of its art, likewise still wraps area type by its bounds when the file is opened, as it did before saving, not by the members of that art: the group starts with the same unpainted rectangle, which takes the object's lock and visibility, and the group keeps the object's name and transparency without options of its own. Area type in that art is above the rectangle, so the rectangle does not wrap it. The rectangle takes its place in the object limit before the art; without room for it, the options are left out with the limit's warning. An object without finite bounds keeps the options on its group. This is VectorCraft's own round-trip rule (`crates/eps/src/ai_editing/tests.rs` `live_art_written_as_a_group_keeps_wrapping_by_its_bounds`, `wrap_bounds_of_live_art_fit_the_object_limit_and_leave_area_type_in_the_art_unwrapped`, `live_art_without_bounds_keeps_its_text_wrap_on_the_group`). In a `.ai` or EPS opened from its editing data, type has its text object's opacity, blend mode and knockout shape flag, whether it is made from the file's text document or taken from the page, and type made from the text document takes its text object's lock. Where such type has transparency and comes in with other art (the rest of its look, or page type and strokes that go with it), a group of them has it. Where the page draws its type, or the strokes around it, with transparency that is neither its text object's nor its text object's combined with that of the objects around it, the page's type and strokes keep their own instead (`crates/eps/src/import/tests_native.rs`). Where the page draws type of no text object over text objects made from the text document, with their words in any case, that type is theirs as the page draws it and is left out; the page's other type of no text object goes only to text objects whose type the text document can't make, or else is left out with a warning. `.ai` editing-data import restores the document's listed graphic styles in panel order and links objects that use a listed style; unsupported appearances keep their drawn look (`crates/eps/src/import/ai/tests.rs`). - Swatches › Open Swatch Library › Other Library… lists `.ai` and `.eps` files in its Swatch Libraries filter and loads another document's swatches ([importing swatches from another document](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=134)): its colors, tints, gradients and pattern swatches, in its order and color groups. Adding a pattern swatch from such a library brings the pattern with its tile and art as a pattern swatch, under the library swatch's name and in its color group. A document with no swatches, and a `.ai` or EPS whose swatches are only the default ones, are refused with a message (`cmd::fileio::tests_aiimport::a_swatch_library_in_a_ai_file_lists_and_adds_its_pattern_swatches`, `a_pattern_from_a_ai_library_keeps_a_color_the_library_lacks`, `swatch_library_documents_without_swatches_or_damaged_are_refused`, `cmd::fileio::tests::the_swatch_library_filter_lists_ai_and_eps_files`). As VectorCraft's own rule, a global or spot color whose name the document gives another color, added from a library on its own, with a tint or with a pattern's art, comes in under a numbered name, and adding it again uses that numbered copy; a library tint or gradient links to it. Use Library Item adds a library pattern's colors the same way (`tests::swatchlib::adding_a_library_pattern_and_its_color_again_reuses_the_numbered_color`, `a_library_tint_follows_its_color_to_its_numbered_name`, `a_library_tint_picked_before_its_color_follows_it_to_its_numbered_name`, `a_library_gradient_is_not_the_one_a_merged_pattern_brought`, `tests::library::a_pattern_item_keeps_its_global_color_when_the_document_has_that_name_in_another_color`). + Swatches › Open Swatch Library › Other Library… lists `.ai` and `.eps` files in its Swatch Libraries filter and loads another document's swatches ([importing swatches from another document](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=134)): its colors, tints, gradients and pattern swatches, in its order and color groups. Adding a pattern swatch from such a library brings the pattern with its tile and art as a pattern swatch, under the library swatch's name and in its color group. A document with no swatches, and a `.ai` or EPS whose swatches are only the default ones, are refused with a message (`cmd::fileio::tests_aiimport::a_swatch_library_in_a_ai_file_lists_and_adds_its_pattern_swatches`, `a_pattern_from_a_ai_library_keeps_a_color_the_library_lacks`, `swatch_library_documents_without_swatches_or_damaged_are_refused`, `cmd::fileio::tests::the_swatch_library_filter_lists_ai_and_eps_files`). As VectorCraft's own rule, a global or spot color whose name the document gives another color, added from a library on its own, with a tint or with a pattern's art, comes in under a numbered name, and adding it again uses that numbered copy; a library tint or gradient links to it, and brings its color when the document lacks it. Use Library Item adds a library pattern's colors the same way (`tests::swatchlib::adding_a_library_pattern_and_its_color_again_reuses_the_numbered_color`, `a_library_tint_follows_its_color_to_its_numbered_name`, `a_library_tint_added_alone_brings_its_color_beside_a_namesake`, `a_library_tint_picked_before_its_color_follows_it_to_its_numbered_name`, `a_library_gradient_is_not_the_one_a_merged_pattern_brought`, `tests::library::a_pattern_item_keeps_its_global_color_when_the_document_has_that_name_in_another_color`). A `.ai` or EPS graphic style library, whose editing data holds the styles and their list but no layers, opens with those styles in list order. Other Library… loads another document's graphic styles ([Apply graphic styles](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/apply-graphic-styles/apply-graphic-styles.html)) and lists such a library's styles in a library panel. A `.ai` or EPS read as its PDF part or page because its layers can't be used also gets the styles of its list in place of the default ones (`crates/eps/src/import/tests_native.rs`, `cmd::fileio::tests_aiimport::a_graphic_style_library_in_a_ai_file_without_layers_loads_its_styles`). A `.ai` or EPS symbol library, whose editing data holds symbol definitions and their list but no layers, opens with those symbols in list order, each with its registration point. Other Library… in the Symbols panel's Symbol Libraries Menu imports the symbols of the file you pick ([Create or import symbol libraries](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/create-or-import-symbol-libraries.html)) and lists such a library's symbols in a library panel. A `.ai` or EPS read as its PDF part or page because its layers can't be used also gets the symbols defined before its layers (`crates/eps/src/import/tests_native.rs`, `crates/eps/src/import/ai/tests.rs`, `cmd::fileio::tests_aiimport::a_symbol_library_in_a_ai_file_without_layers_loads_its_symbols`). In a large canvas `.ai` or EPS ([Large canvas FAQ](https://helpx.adobe.com/illustrator/desktop/add-and-import-files/start-a-new-file/large-canvas-faq.html)), or a `.ai` whose page is in larger units, opened from its editing data, VectorCraft reads the symbol definitions in the same units as the layers. When the file opens at its full size, each symbol's art, strokes and effects are scaled with the layers, and each instance keeps its own scale and rotation and draws where and as large as before. A new instance comes in at the symbol's full size, the size of an instance at 100% in the file. A symbol library from such a file comes in at the same size, and opacity masks on the layers that don't move with their object are scaled with the layers too. Editing data that VectorCraft wrote keeps its symbols and those masks at their own size, as its `.ai` save writes them (`tests_native::a_large_canvas_eps_keeps_its_symbols_at_the_pages_size`, `a_large_canvas_ai_keeps_its_symbols_at_the_pages_size`, `a_large_canvas_ai_vectorcraft_wrote_keeps_its_symbols_at_their_own_size`, `a_symbol_library_in_larger_units_comes_in_at_the_pages_size`, `build::candidate_tests::scaling_the_symbols_keeps_their_instances_in_place`, `scaling_a_read_document_scales_unlinked_opacity_masks`).