.ai import: symbol libraries open with their symbols

A .ai or EPS whose editing data defines symbols but has no layers came
in as its PDF part or page without symbols, and Other Library in the
Symbols panel listed none. Such a file, and a file read as its PDF part
or page because its layers can't be used, now gets the symbols its
editing data defines before its first layer, as a file read from its
layers does: File > Open shows them in the Symbols panel in the order
of the symbol list, and Other Library lists them in a library panel.

- Each symbol keeps its registration point. A symbol that holds an
  instance of a symbol the file doesn't define is left out, and an
  object linked to a listed graphic style keeps the link.
- The symbols' art takes ids of the document, the art of opacity masks
  in it included, and the images it shows come with it. Instances
  drawn too deep are removed with the usual note.
- The global and spot colors the art is linked to come in as swatches.
  A color whose name another swatch has takes that swatch's place when
  it is a default swatch of a file without a palette; otherwise it
  comes in under a free variant of the name ("Ink 2"), which the art
  then names.
- Symbol art keeps the editing data's units, as in a file read from its
  layers, so in a file in larger units its linked graphic styles are
  drawn at the scaled size and the symbol art is not.
- The art of the patterns a palette or brush brings into a file read as
  its PDF part or page now also takes new ids for its opacity masks.

Part of #3349
This commit is contained in:
dotCooCoo
2026-11-07 05:29:38 -08:00
parent ff9deee46d
commit 2a32d1bc65
12 changed files with 519 additions and 27 deletions
@@ -398,6 +398,39 @@ fn a_graphic_style_library_in_a_ai_file_without_layers_loads_its_styles() {
assert_eq!(styles, [("Red", 1), ("Green", 2), ("Blue", 3)], "{r}");
}
/// A `.ai` symbol library (symbols and their list, no layers) opens with its symbols, and Other
/// Library… in the Symbols panel lists them in the list's order.
#[test]
fn a_symbol_library_in_a_ai_file_without_layers_loads_its_symbols() {
let symbol = |name: &str, x: f64| {
format!(
"%AI14_BeginSymbol\n({name})\n0 A\n0 Xw\n0 Ae\nu\n0 1 1 0 1 0 0 Xa\n{x} 0 m\n{x} 4 L\n{} 4 L\n{} 0 L\nf\nU\n\
%_/ArtDictionary :\n%_5 /Int (AI13PatternRegistrationType) ,\n%_;\n%_\n9 () XW\n%AI10_EndSymbol\n",
x + 4.0,
x + 4.0
)
};
let symbols = format!(
"%AI5_Begin_NonPrinting\n{}{}{}%AI5_End_NonPrinting--\n%AI24_BeginSymbolList\n(Star)\n(Leaf)\n(Arrow)\n%AI24_EndSymbolList\n",
symbol("Arrow", 0.0),
symbol("Leaf", 10.0),
symbol("Star", 20.0)
);
let data = ai::editing_data(200.0, 100.0, &symbols);
let file = ai::ai(&compressed(data.as_bytes()), "1 0 0 rg 10 50 30 40 re f");
let mut s = Session::new();
let p = json!({"dataBase64": vectorcraft_format::base64_encode(&file), "name": "shapes.ai"});
let r = s.execute("symbol.loadLibrary", &p).unwrap();
assert_eq!((&r["name"], &r["count"]), (&json!("shapes"), &json!(3)), "{r}");
let lib = s.execute("symbol.library", &json!({"library": r["library"]})).unwrap();
let names: Vec<&str> = lib["symbols"].as_array().unwrap().iter().map(|g| g["name"].as_str().unwrap()).collect();
assert_eq!(names, ["Star", "Leaf", "Arrow"], "{lib}");
let r = open(&mut s, "shapes.ai", &file, json!({})).unwrap();
let doc = &s.doc().unwrap().doc;
let names: Vec<&str> = doc.symbols.iter().map(|g| g.name.as_str()).collect();
assert_eq!(names, ["Star", "Leaf", "Arrow"], "{r}");
}
/// A 1-bit RGB image opens from the editing data in the colors its PDF part shows.
#[test]
fn a_one_bit_rgb_image_opens_from_the_editing_data_in_its_colors() {
+30
View File
@@ -3690,9 +3690,36 @@ proptest! {
let private = [b"%AI24_ZStandard_Data".as_slice(), &zstd(&text)].concat();
survive("mutated .ai symbols", || Some(vectorcraft_eps::layered_ai(&private, Document::new(200.0, 100.0), vec![], false, false, 1.0).0))?;
survive("mutated .ai symbols, trusted", || Some(vectorcraft_eps::layered_ai(&private, Document::new(200.0, 100.0), vec![], false, true, 1.0).0))?;
// A symbol library: the same symbols and list, no layers.
let library = mutate_text(&symbol_library_text(), cut, &edits);
let private = [b"%AI24_ZStandard_Data".as_slice(), &zstd(&library)].concat();
survive("mutated .ai symbol library", || Some(vectorcraft_eps::layered_ai(&private, Document::new(200.0, 100.0), vec![], false, false, 1.0).0))?;
let eps = vectorcraft_testkit::ai::eps(library.as_bytes(), vectorcraft_testkit::ai::page_ps());
survive("mutated symbol library in an EPS", || vectorcraft_engine::cmd::fileio::load("x.eps", &eps).ok().map(|l| l.doc))?;
}
}
/// [`symbols_text`] without its layer: a symbol library.
fn symbol_library_text() -> String {
let full = symbols_text();
match (full.find("%AI5_BeginLayer"), full.find("%AI5_EndLayer--\n")) {
(Some(a), Some(b)) if a < b => format!("{}{}", &full[..a], &full[b + "%AI5_EndLayer--\n".len()..]),
_ => full,
}
}
/// The library [`ai_symbols_never_panic`] damages, as it is, opens with its symbols.
#[test]
fn the_symbol_library_fuzz_data_opens_with_its_symbols() {
let text = symbol_library_text();
assert!(!text.contains("%AI5_BeginLayer"));
let private = [b"%AI24_ZStandard_Data".as_slice(), &zstd(&text)].concat();
let (doc, warnings, layered) = vectorcraft_eps::layered_ai(&private, Document::new(200.0, 100.0), vec![], false, false, 1.0);
assert!(!layered, "{warnings:?}");
let names: Vec<&str> = doc.symbols.iter().map(|s| s.name.as_str()).collect();
assert_eq!(names, ["S2", "S1"], "{warnings:?}");
}
/// Editing data with symbols (S2's art holds an instance of S1, F's holds non-native art), the
/// symbol list and a layer of instances, as the format writes them.
fn symbols_text() -> String {
@@ -3783,6 +3810,9 @@ fn ai_symbol_limits_never_panic() {
ai::layer("L", &inst("(S1)", "1 0 0 -1 20 50"))
),
format!("{}{}", def("S1", &inst("(S2)", "1 0 0 -1 0 0")), def("S2", &inst("(S1)", "1 0 0 -1 0 0"))),
// Symbol libraries without layers: definitions nested too deep and a long chain.
nested,
chain,
];
for body in cases {
let data = ai::editing_data(200.0, 100.0, &body).replacen("%%EndComments", "%AI3_TemplateBox: 100.5 50.5 100.5 50.5\n%%EndComments", 1);
+2 -2
View File
@@ -38,8 +38,8 @@ pub(crate) use envelope::DRAWN as ENVELOPE_DRAWN;
pub(crate) use frames::text_frames;
pub(crate) use paint::MAX_STOPS as MAX_GRADIENT_STOPS;
pub use read::{
BindingRef, Brushes, IMAGE_TOO_LARGE, PaletteSwatches, Structure, artboards, bindings_note, brushes, graphic_styles, palette, read, read_beside,
variables,
BindingRef, Brushes, IMAGE_TOO_LARGE, PaletteSwatches, Structure, Symbols, artboards, bindings_note, brushes, graphic_styles, palette, read,
read_beside, symbols, variables,
};
pub(crate) use read::{join_and, slot_frame, slot_of};
+3 -1
View File
@@ -134,7 +134,9 @@ mod types;
pub(crate) use art::join_and;
use art::preview_png;
pub use document::{BindingRef, Brushes, PaletteSwatches, VariableRead, artboards, bindings_note, brushes, graphic_styles, palette, variables};
pub use document::{
BindingRef, Brushes, PaletteSwatches, Symbols, VariableRead, artboards, bindings_note, brushes, graphic_styles, palette, symbols, variables,
};
pub(crate) use document::{slot_frame, slot_of};
pub use types::IMAGE_TOO_LARGE;
use types::{BLEND_BUDGET, FLIP, Frame, GState, Graph, Kind, PatternHead, PendingEnvelope, Place, Raster, SymbolHead};
+67
View File
@@ -390,6 +390,73 @@ pub fn graphic_styles(data: &[u8], large_canvas: bool) -> (Vec<GraphicStyle>, f6
(r.graphic_styles().0, r.canvas_scale)
}
/// The symbols of a `.ai` file's editing data, as [`symbols`] reads them.
pub struct Symbols {
/// The symbols in the Symbols panel's order, each with its Symbol Options › Registration.
pub symbols: Vec<(Symbol, vectorcraft_doc::SymbolRegistration)>,
/// The image blobs the symbols' art shows, by key.
pub images: std::collections::BTreeMap<String, ImageBlob>,
/// The global and spot colors the symbols' art is linked to, as swatches, as [`read`] adds
/// them to a document read from the layers.
pub swatches: Vec<Swatch>,
}
/// The symbols of the editing data `data`, for a file whose layers aren't read (a symbol library
/// has none), as [`read`] makes them: in the symbol list's order, without those that hold an
/// instance of a symbol the data doesn't define, and with each object of their art that is linked
/// to a listed graphic style linked to it by the id [`graphic_styles`] gives that style. The
/// symbols are those defined before reading stops and before the first layer; `None` when there
/// are none.
pub fn symbols(data: &[u8]) -> Option<Symbols> {
crate::import::ai::find(data, b"BeginSymbol")?;
let mut r = Reader::with_names(data);
// The symbols come before the art, so an error in the art leaves them read.
let _ = r.run();
r.check_symbols();
r.order_symbols();
if r.doc.symbols.is_empty() {
return None;
}
let (styles, ids) = r.graphic_styles();
let links: HashMap<NodeId, u32> = r.style_links.iter().filter_map(|(node, name)| Some((*node, *ids.get(name)?))).collect();
if !links.is_empty() {
for symbol in &mut r.doc.symbols {
link_styles(std::slice::from_mut(&mut symbol.art), &links, &styles, 0);
}
}
let mut shown = Document::new(1.0, 1.0);
shown.symbols = std::mem::take(&mut r.doc.symbols);
let mut images = std::collections::BTreeMap::new();
shown.visit_images(|_, im| {
if let Some(blob) = r.doc.images.get(&im.key) {
images.insert(im.key.clone(), blob.clone());
}
});
// The colors the art is linked to that the file defines, once each.
let mut linked = std::collections::HashSet::new();
for s in &mut shown.symbols {
vectorcraft_doc::swatches::map_node_solid_paints(Arc::make_mut(&mut s.art), &mut |_, link, _| {
linked.extend(link.clone());
false
});
}
let mut swatches: Vec<Swatch> = vec![];
let colors = r.spots.iter().chain(&r.stop_spots).map(|n| (n, n.spot)).chain(r.custom_colors.iter().map(|n| (n, true)));
for (n, spot) in colors {
if linked.remove(&n.name) {
swatches.push(Swatch { name: n.name.clone(), paint: Paint::solid(n.color), global: true, spot });
}
}
let symbols = std::mem::take(&mut shown.symbols)
.into_iter()
.map(|s| {
let reg = r.doc.symbol_registration(&s.name);
(s, reg)
})
.collect();
Some(Symbols { symbols, images, swatches })
}
/// [`artboards`] as far as reading `data` from its start gets: those read before an error, and
/// those of a `/Document` still open when it stopped (its art can be what stopped it).
fn artboards_read(data: &[u8]) -> (Vec<(String, Rect)>, Option<usize>) {
+44
View File
@@ -5463,6 +5463,50 @@ fn an_object_in_a_symbols_art_with_a_listed_style_is_linked() {
assert_eq!(art.extras().graphic_style, Some(1), "{art:#?}");
}
/// Editing data with symbols and no layers (a symbol library) gives its symbols: in the symbol
/// list's order with the unlisted one after them, with their registration points and the images
/// their art shows, without the one holding an instance of a symbol the data doesn't define, and
/// with the object linked to a listed graphic style linked to it by its id.
#[test]
fn a_symbol_library_without_layers_gives_its_symbols() {
let styles = styles_and_list(&[fill_style("Blue", "0 0 0 0 0 0 1 Xa\n")], &["Blue"]);
// The template box's center is (100.5, 50.5): art space's origin is at canvas (8091, 8242).
let nested = instance("Dot", [1.0, 0.0, 0.0, -1.0, -8081.0, 8237.0]);
let lost = instance("Ghost", [1.0, 0.0, 0.0, -1.0, -8081.0, 8237.0]);
let m = "[ 5 0 0 5 -8096 8244.5 ]";
let raster = format!(
"%AI5_File:\n%AI5_BeginRaster\n() 1 XG\n/DeviceRGB XN\n{m} 2 1 0 Xh\n{m} 0 0 2 1 2 1 8 3 0 0 1 0 4 4 0 0\n\
%%BeginData: 6\rXI\nABCDEF%%EndData\r\nXH\r\n%AI5_EndRaster\r\nN\n"
);
let defs = symbols(
&(symbol("Dot", &dot(), 1)
+ &symbol("Pic", &raster, 5)
+ &symbol("Pair", &nested, 5)
+ &symbol("Tile", &styled_square("Blue"), 5)
+ &symbol("Lost", &lost, 5)),
);
let list = "%AI24_BeginSymbolList\n(Tile)\n(Pair)\n(Lost)\n(Dot)\n%AI24_EndSymbolList\n";
let body = format!("%AI3_TemplateBox: 100.5 50.5 100.5 50.5\n{styles}{defs}{list}");
let read = super::symbols(stream(&body).as_bytes()).expect("the library's symbols");
let names: Vec<&str> = read.symbols.iter().map(|(s, _)| s.name.as_str()).collect();
assert_eq!(names, ["Tile", "Pair", "Dot", "Pic"]);
let registrations: Vec<u8> = read.symbols.iter().map(|(_, r)| r.0).collect();
let center = vectorcraft_doc::SymbolRegistration::CENTER.0;
assert_eq!(registrations, [center, center, 0, center]);
let Some(((tile, _), (pair, _))) = read.symbols.first().zip(read.symbols.get(1)) else { panic!("two symbols") };
assert_eq!(tile.art.extras().graphic_style, Some(1), "{:#?}", tile.art);
// Dot sits at (10, 5) in Pair's art.
let mut doc = Document::new(1.0, 1.0);
doc.symbols = read.symbols.iter().map(|(s, _)| s.clone()).collect();
assert_eq!(pair.art.visual_bounds_with(&doc.symbol_boxes()), Some(Rect::new(8.0, 3.0, 12.0, 7.0)));
let keys: Vec<String> =
doc.symbols.iter().filter_map(|s| if let NodeKind::Image(im) = &s.art.kind { Some(im.key.clone()) } else { None }).collect();
assert_eq!(keys.len(), 1);
assert_eq!(read.images.keys().cloned().collect::<Vec<_>>(), keys);
// Without symbols there are none to give.
assert!(super::symbols(stream(&styles).as_bytes()).is_none());
}
#[test]
fn without_a_style_list_the_default_graphic_styles_stay() {
let defaults = style_names(&Document::new(1.0, 1.0));
+1 -1
View File
@@ -1094,7 +1094,7 @@ fn keep_differing(
}
/// Copy page drawing IDs, including mask art outside the ordinary child tree.
fn reid_page_art(doc: &mut Document, source: &Node) -> Node {
pub(super) fn reid_page_art(doc: &mut Document, source: &Node) -> Node {
let mut copy = doc.reid(source);
if let Some(mask) = &mut copy.extras_mut().mask {
mask.art = Arc::new(reid_page_art(doc, &mask.art));
+83 -18
View File
@@ -1,4 +1,4 @@
use super::build::{PAGE_MOVE, Page, build, build_from, build_on_page, build_without_page};
use super::build::{PAGE_MOVE, Page, build, build_from, build_on_page, build_without_page, reid_page_art};
use super::slots::LAYERS_UNREAD;
use super::{Affine, Arc, Cow, Document, Imported, Node, NodeKind, PathData, Rect, Vec2, ai};
@@ -7,11 +7,11 @@ use super::{Affine, Arc, Cow, Document, Imported, Node, NodeKind, PathData, Rect
/// hidden ones too), groups, compound paths, clipping groups and artboards, with the text and the
/// strokes around it of the page. When the file has no editing copy, `visible` as it was; when it
/// has one that can't be used, `visible` with a warning that says why, with the swatches of the
/// editing copy's palette ([`use_palette`]), its graphic styles ([`use_styles`]) and its variable
/// library ([`use_variables`]) when it could be read, and with its layer tree, empty,
/// below the page's layer when that could be read (#2033). A program in the legacy format without
/// layers (`illustrator`, see [`program_alone`]) is read with its art on one layer; when that
/// can't be used, the file is `visible` as it was.
/// editing copy's palette ([`use_palette`]), its graphic styles ([`use_styles`]), its symbols
/// ([`use_symbols`]) and its variable library ([`use_variables`]) when it could be read, and with
/// its layer tree, empty, below the page's layer when that could be read (#2033). A program in the
/// legacy format without layers (`illustrator`, see [`program_alone`]) is read with its art on one
/// layer; when that can't be used, the file is `visible` as it was.
pub(in super::super) fn layered(ps: &[u8], visible: Imported, trust: bool, illustrator: bool) -> Imported {
let Some(data) = editing_copy(ps) else {
let read = illustrator.then(|| one_layer(ps)).flatten().and_then(|p| build(&p, Some(&visible.document), Page::Art, false, trust, 1.0).ok());
@@ -38,9 +38,10 @@ pub(in super::super) fn layered(ps: &[u8], visible: Imported, trust: bool, illus
let mut v = visible;
if let Ok(data) = &data {
let have = v.document.patterns.len();
use_palette(data, &mut v.document);
let own_palette = use_palette(data, &mut v.document);
use_brushes(data, &mut v.document, have, &mut v.warnings);
use_styles(data, &mut v.document, true, 1.0, None);
use_symbols(data, &mut v.document, own_palette, &mut v.warnings);
use_variables(data, &mut v.document, &mut v.warnings);
}
if tree.is_empty() {
@@ -100,10 +101,11 @@ fn layer_tree(nodes: &[Arc<Node>]) -> Vec<Arc<Node>> {
/// notes, or a note saying why the layers weren't read when the editing data can't be decompressed
/// or its layers can't be read. The flag returned is `true` when the document is the one read from
/// the layers; else the document is `visible`, its pages moved by `place_pages` when the editing
/// data was decompressed but its layers can't be read, and its swatches, brushes, graphic styles and
/// variables those of the editing data's palette ([`use_palette`]), brushes ([`use_brushes`]), styles
/// ([`use_styles`]) and variable library ([`use_variables`]) when it was decompressed: a graphic
/// style library, which has no layers, opens with its styles, and editing data with no layers opens
/// data was decompressed but its layers can't be read, and its swatches, brushes, graphic styles,
/// symbols and variables those of the editing data's palette ([`use_palette`]), brushes
/// ([`use_brushes`]), styles ([`use_styles`]), symbols ([`use_symbols`]) and variable library
/// ([`use_variables`]) when it was decompressed: a graphic style library or a symbol library, which
/// has no layers, opens with its styles or its symbols, and editing data with no layers opens
/// on the page of its active artboard under the checks of `place_pages`. `outlined`: the PDF part's type was
/// read as outlines (a file whose type shows then comes in as its PDF part).
/// `trust`: layers that draw differently from the PDF part are used all the same, with a warning.
@@ -140,9 +142,10 @@ pub fn layered_ai_from(
visible.opened_artboard = active_page(active, &visible);
}
let have = visible.patterns.len();
use_palette(&data, &mut visible);
let own_palette = use_palette(&data, &mut visible);
use_brushes(&data, &mut visible, have, &mut warnings);
use_styles(&data, &mut visible, false, unit, Some(&boards));
use_symbols(&data, &mut visible, own_palette, &mut warnings);
use_variables(&data, &mut visible, &mut warnings);
return (visible, warnings, false);
}
@@ -152,10 +155,11 @@ pub fn layered_ai_from(
let (boards, active) = ai::artboards(&data);
place_pages(&boards, active, &mut visible, unit);
let have = visible.patterns.len();
use_palette(&data, &mut visible);
let own_palette = use_palette(&data, &mut visible);
use_brushes(&data, &mut visible, have, &mut warnings);
use_styles(&data, &mut visible, false, unit, Some(&boards));
let mut all = unread(warnings, why);
use_symbols(&data, &mut visible, own_palette, &mut all);
use_variables(&data, &mut visible, &mut all);
(visible, all, false)
};
@@ -243,14 +247,14 @@ fn use_variables(data: &[u8], doc: &mut Document, warnings: &mut Vec<String>) {
/// palette doesn't have follow the palette's swatches. The patterns that the editing data defines come
/// in for the palette's pattern swatches, with the images they show; one whose name a pattern of
/// the PDF part already has takes a free variant of it ([`ai::palette`]). Left as
/// it is when the palette is empty.
fn use_palette(data: &[u8], doc: &mut Document) {
let Some(ai::PaletteSwatches { swatches, groups, patterns, images }) = ai::palette(data, &doc.patterns) else { return };
/// it is when the palette is empty. Whether the palette's swatches came in.
fn use_palette(data: &[u8], doc: &mut Document) -> bool {
let Some(ai::PaletteSwatches { swatches, groups, patterns, images }) = ai::palette(data, &doc.patterns) else { return false };
for (key, blob) in images {
doc.images.entry(key).or_insert(blob);
}
for mut p in patterns {
p.art = p.art.iter().map(|n| Arc::new(doc.reid(n))).collect();
p.art = p.art.iter().map(|n| Arc::new(reid_page_art(doc, n))).collect();
doc.patterns.push(p);
}
let named = |name: &str| swatches.iter().chain(groups.iter().flat_map(|g| &g.swatches)).any(|s| s.name == name);
@@ -259,6 +263,7 @@ fn use_palette(data: &[u8], doc: &mut Document) {
let mut swatches = swatches;
swatches.extend(art);
(doc.swatches, doc.swatch_groups) = (swatches.into(), groups.into());
true
}
/// `doc` (a file read as its page or PDF part, in place of its layers) with the brushes of its
@@ -277,7 +282,7 @@ fn use_brushes(data: &[u8], doc: &mut Document, have: usize, warnings: &mut Vec<
if doc.pattern(&p.name).is_some() {
continue;
}
p.art = p.art.iter().map(|n| Arc::new(doc.reid(n))).collect();
p.art = p.art.iter().map(|n| Arc::new(reid_page_art(doc, n))).collect();
doc.patterns.push(p);
}
vectorcraft_brush::store(doc, &brushes);
@@ -317,6 +322,66 @@ fn use_styles(data: &[u8], doc: &mut Document, large_canvas: bool, unit: f64, bo
doc.graphic_styles = styles.into();
}
/// `doc` (a file read as its page or PDF part, in place of its layers) with the symbols of its
/// editing data `data` ([`ai::symbols`]), their registration points, the images their art shows and
/// the global and spot colors it is linked to that `doc` has no such swatch for (a color whose name
/// another swatch has takes that swatch's place when it is a default swatch and not `own_palette`,
/// the swatches being those of the editing data's palette, and else comes in under a free variant
/// of the name, which the art then names), as [`build`] gives a document read from the layers, and
/// the note about instances that can't be drawn added to `warnings`. An object of their art linked
/// to a graphic style keeps the link when [`use_styles`] gave `doc` the editing data's styles. The
/// symbols' art keeps the editing data's units, as in a document read from the layers: when
/// [`use_styles`] draws the styles' strokes and effects larger (a file in larger units), linked art
/// isn't scaled with them. Left as it is when `doc` has symbols already or the editing data has
/// none this reads.
fn use_symbols(data: &[u8], doc: &mut Document, own_palette: bool, warnings: &mut Vec<String>) {
if !doc.symbols.is_empty() {
return;
}
let Some(ai::Symbols { symbols, images, swatches }) = ai::symbols(data) else { return };
for (key, blob) in images {
doc.images.entry(key).or_insert(blob);
}
// A color whose name a swatch of another color has takes that swatch's place when it is a
// default swatch, and else a free variant of the name.
let (defaults, groups) = vectorcraft_color::default_swatches(doc.color_mode.model());
let is_default =
|have: &vectorcraft_color::Swatch| !own_palette && defaults.iter().chain(groups.iter().flat_map(|g| &g.swatches)).any(|d| d == have);
let mut renamed = std::collections::HashMap::new();
for s in swatches {
match doc.swatch(&s.name) {
None => doc.swatches.push(s),
Some(have) if have == &s || (s.name.starts_with('[') && s.name.ends_with(']')) => {}
Some(have) if is_default(have) => {
if let Some(default) = doc.swatch_mut(&s.name) {
*default = s;
}
}
Some(_) => {
let name = doc.free_swatch_name(&s.name);
renamed.insert(s.name.clone(), name.clone());
doc.swatches.push(vectorcraft_color::Swatch { name, ..s });
}
}
}
let mut follow = |_: &mut vectorcraft_color::Color, link: &mut Option<String>, _: &mut f32| {
let Some(new) = link.as_ref().and_then(|l| renamed.get(l)) else { return false };
*link = Some(new.clone());
true
};
for (mut symbol, registration) in symbols {
let mut art = reid_page_art(doc, &symbol.art);
if !renamed.is_empty() {
vectorcraft_doc::swatches::map_node_solid_paints(&mut art, &mut follow);
}
symbol.art = Arc::new(art);
doc.set_symbol_registration(&symbol.name, registration);
doc.symbols.push(symbol);
}
// Symbols that hold instances of themselves can't be drawn: those instances go.
doc.limit_depth_noting(warnings);
}
/// How many points a unit of `boards` (the artboards of a file's editing data, in art space) is in
/// `doc` (the file read as its PDF part: a page per artboard): 1 when there are as many artboards as
/// pages, each the size of its page in points, or `unit` when `unit` is above 1 and each is the size
+248
View File
@@ -1356,6 +1356,37 @@ fn an_ai_file_without_layers_keeps_the_patterns_of_its_palette() {
assert!(keys.iter().all(|k| d.images.contains_key(k)), "{keys:?}");
}
/// The art of a pattern with an opacity mask that a palette swatch or a brush's art paints with,
/// in a file without layers, takes ids of the document, its mask's art included.
#[test]
fn a_pattern_of_a_file_without_layers_takes_ids_for_its_mask_art() {
let mask_art: String = symbol_square(0.0, 0.0, 4.0, 4.0).replace("0 1 1 0 1 0 0 Xa", "1 g").lines().map(|l| format!("%_{l}\n")).collect();
let mask = format!("%_/ArtDictionary :\n%_/Mask :\n%_X=\n{mask_art}%_X+\n%_(Art) ,\n%_1 /Bool (Clipping) ,\n%_; (AI9_Mask) ,\n%_;\n");
let hidden = |art: String| -> String { art.lines().map(|l| format!("%_{l}\n")).collect() };
let tile = format!("{}{mask}{}", hidden(symbol_square(0.0, 0.0, 4.0, 4.0)), hidden(symbol_square(1.0, 1.0, 3.0, 3.0)));
let dots = format!("%AI3_BeginPattern: (Dots)\n(Dots) 0 0 4 4\n{tile}E\n%AI3_EndPattern\n");
let palette = "%AI5_BeginPalette\n0 0 Pb\n(Dots) 0 0 1 1 0 0 0 0 0 [1 0 0 1 0 0] p\n(Dots)\nPc\nPB\n%AI5_EndPalette\n";
let order = "%AI8_BeginPluginObject\n(Adobe Brush Manager Order)\n(Adobe Brush Manager Order)\n( Adobe Scatter Brush Tool/ Spray/) .\n%AI8_EndPluginObject\n";
let spray = "%AI8_BeginPluginObject\n(Adobe Scatter Brush Tool)\n(Spray)\n(2 /Dot art/ 5 1 0 0 / 0 0.5 1.5 1 ) -\n\
(1.2 2 0 -0.25 0.25 2 -45 30 1 1 0) .\n%AI8_EndPluginObject\n";
let dot = "%AI8_BeginBrushPattern\n(Dot art)\n(Dots) 0 0 1 1 0 0 0 0 0 [1 0 0 1 0 0] p\n0 0 m\n4 0 L\n4 4 L\nf\n%AI8_EndBrushPattern\n";
for setup in [format!("{dots}{palette}"), format!("{dots}{dot}{order}{spray}")] {
let library = format!("%!PS-Adobe-3.0 \n%%BoundingBox: 0 0 100 100\n%%BeginSetup\n{setup}%%EndSetup\n%%PageTrailer\n%%Trailer\n");
let (d, warnings, read) = crate::layered_ai(&private(&library), pdf_part(10.0, 86.0), vec![], false, true, 1.0);
assert!(!read, "{warnings:?}");
let art = d.pattern("Dots").map(|p| p.art.clone()).unwrap_or_default();
let mut masked = art.iter().flat_map(|n| std::iter::once(n).chain(n.children().into_iter().flatten()));
assert!(masked.any(|n| n.extras().mask.is_some()), "the mask is read: {art:#?} {warnings:?}");
let mut ids = vec![];
for n in d.layers.iter().chain(d.patterns.iter().flat_map(|p| &p.art)) {
all_ids(n, &mut ids);
}
let unique: std::collections::HashSet<_> = ids.iter().copied().collect();
assert_eq!(unique.len(), ids.len(), "{ids:?}");
assert!(ids.iter().all(|id| id.0 < d.peek_next_id()), "{ids:?}");
}
}
/// A brush library (brush objects and their art, no layers) comes in as its PDF part with the
/// library's brushes in place of the default ones: Other Library lists them.
#[test]
@@ -1486,6 +1517,223 @@ fn a_file_whose_layers_cant_be_used_keeps_its_graphic_styles() {
assert_eq!(names(&r.document), ["Thin", "Medium", "Thick"], "{:?}", r.warnings);
}
/// A symbol named `name` whose art is `art` (in the symbol's space, y down), with the registration
/// point `registration` (1 to 9 from the top left, row by row), as the editing data defines it.
fn symbol_def(name: &str, art: &str, registration: u32) -> String {
format!(
"%AI14_BeginSymbol\n({name})\n0 A\n0 Xw\n0 Ae\nu\n{art}U\n%_/ArtDictionary :\n%_{registration} /Int (AI13PatternRegistrationType) ,\n%_;\n%_\n9 () XW\n%AI10_EndSymbol\n"
)
}
/// A red square from (`x0`, `y0`) to (`x1`, `y1`), as a symbol's art.
fn symbol_square(x0: f64, y0: f64, x1: f64, y1: f64) -> String {
format!("0 1 1 0 1 0 0 Xa\n{x0} {y0} m\n{x0} {y1} L\n{x1} {y1} L\n{x1} {y0} L\n{x0} {y0} L\nf\n")
}
/// The symbols Dot (a square of 4 about the origin, registered at its top left), Bar (12 × 2 about
/// the origin) and Masked (a square with an opacity mask), listed as Bar, Masked, Dot.
fn symbol_defs() -> String {
let mask_art: String = symbol_square(-2.0, -2.0, 2.0, 2.0).replace("0 1 1 0 1 0 0 Xa", "1 g").lines().map(|l| format!("%_{l}\n")).collect();
let mask = format!("%_/ArtDictionary :\n%_/Mask :\n%_X=\n{mask_art}%_X+\n%_(Art) ,\n%_1 /Bool (Clipping) ,\n%_; (AI9_Mask) ,\n%_;\n");
let masked = format!("{}{mask}{}", symbol_square(-2.0, -2.0, 2.0, 2.0), symbol_square(-1.0, -1.0, 1.0, 1.0));
let defs = symbol_def("Dot", &symbol_square(-2.0, -2.0, 2.0, 2.0), 1)
+ &symbol_def("Bar", &symbol_square(-6.0, -1.0, 6.0, 1.0), 5)
+ &symbol_def("Masked", &masked, 5);
format!("%AI5_Begin_NonPrinting\n{defs}%AI5_End_NonPrinting--\n%AI24_BeginSymbolList\n(Bar)\n(Masked)\n(Dot)\n%AI24_EndSymbolList\n")
}
/// A symbol library (the symbols of [`symbol_defs`], and no layers).
fn symbol_library() -> String {
format!("%!PS-Adobe-3.0 \n%%BoundingBox: 0 0 100 100\n%%BeginSetup\n{}%%EndSetup\n%%PageTrailer\n%%Trailer\n", symbol_defs())
}
/// The ids of `n`, what it holds and the art of its opacity masks.
fn all_ids(n: &Node, out: &mut Vec<vectorcraft_doc::NodeId>) {
out.push(n.id);
if let Some(m) = n.extras().mask.as_ref() {
all_ids(&m.art, out);
}
for c in n.children().into_iter().flatten() {
all_ids(c, out);
}
}
/// The names of the symbols of `d`, in the Symbols panel's order.
fn symbol_names(d: &Document) -> Vec<&str> {
d.symbols.iter().map(|s| s.name.as_str()).collect()
}
/// A symbol library comes in as its PDF part with the library's symbols, in the list's order, with
/// their registration points: Other Library lists them. Their art takes ids of the document, the
/// art of an opacity mask in it included.
#[test]
fn an_ai_symbol_library_without_layers_keeps_its_symbols() {
let (d, warnings, read) = crate::layered_ai(&private(&symbol_library()), pdf_part(10.0, 86.0), vec![], false, true, 1.0);
assert!(!read, "{warnings:?}");
assert_eq!(symbol_names(&d), ["Bar", "Masked", "Dot"], "{warnings:?}");
assert_eq!(d.symbol_registration("Dot"), vectorcraft_doc::SymbolRegistration(0));
assert!(d.symbol_registration("Bar").is_center());
let boxes = d.symbol_boxes();
let bar = d.symbols.first().and_then(|s| s.art.visual_bounds_with(&boxes));
assert_eq!(bar, Some(vectorcraft_geom::Rect::new(-6.0, -1.0, 6.0, 1.0)));
drop(boxes);
let mut ids = vec![];
for n in d.layers.iter().chain(d.symbols.iter().map(|s| &s.art)) {
all_ids(n, &mut ids);
}
let masked = d.symbols.get(1).map(|s| &s.art);
assert!(masked.is_some_and(|a| a.children().into_iter().flatten().any(|c| c.extras().mask.is_some())), "the mask is read");
let unique: std::collections::HashSet<_> = ids.iter().copied().collect();
assert_eq!(unique.len(), ids.len(), "{ids:?}");
assert!(warnings.is_empty(), "{warnings:?}");
// Without symbols, the PDF part's (none) stay.
let (d, warnings, _) = crate::layered_ai(&private(&native("")), pdf_part(10.0, 86.0), vec![], false, true, 1.0);
assert!(d.symbols.is_empty(), "{warnings:?}");
}
/// An EPS whose editing copy has symbols and no layers comes in as its page with those symbols.
#[test]
fn an_eps_without_layers_keeps_its_symbols() {
let r = import(&eps(&page_square(50, 50), &symbol_library())).unwrap();
assert_eq!(symbol_names(&r.document), ["Bar", "Masked", "Dot"], "{:?}", r.warnings);
}
/// A `.ai` that comes in as its PDF part, and an EPS that comes in as its page, because their
/// layers can't be used (their editing data is for another page) get the symbols defined before
/// their layers.
#[test]
fn a_file_whose_layers_cant_be_used_keeps_its_symbols() {
let art = native(&format!("{}{}", symbol_defs(), layer("Art", true, &square(10, 10)))).replace(" 0 0 100 100", " 0 0 600 400");
let (d, warnings, read) = crate::layered_ai(&private(&art), pdf_part(10.0, 86.0), vec![], false, false, 1.0);
assert!(!read && warnings.iter().any(|w| w.contains("600 × 400")), "{warnings:?}");
assert_eq!(symbol_names(&d), ["Bar", "Masked", "Dot"], "{warnings:?}");
let r = import(&eps(&page_square(10, 10), &art)).unwrap();
assert!(r.warnings.iter().any(|w| w.contains("600 × 400")), "{:?}", r.warnings);
assert_eq!(symbol_names(&r.document), ["Bar", "Masked", "Dot"], "{:?}", r.warnings);
}
/// A symbol library's symbols bring the spot colors their art is linked to. A color whose name a
/// swatch of the library's palette has for another color comes in under a free variant of the
/// name, which the art then names, as it does for an ink of the PDF part; without a palette, it
/// takes the place of the default swatch of that name.
#[test]
fn an_ai_symbol_librarys_symbols_keep_their_spot_colors() {
let library = |setup: &str, ink: &str| {
let art = format!("0 0 1 0 ({ink}) 1 x\n-2 -2 m\n-2 2 L\n2 2 L\n2 -2 L\n-2 -2 L\nf\n");
let defs = format!("{setup}%AI5_Begin_NonPrinting\n{}%AI5_End_NonPrinting--\n", symbol_def("Inked", &art, 5));
format!("%!PS-Adobe-3.0 \n%%BoundingBox: 0 0 100 100\n%%BeginSetup\n{defs}%%EndSetup\n%%PageTrailer\n%%Trailer\n")
};
let open = |text: &str| crate::layered_ai(&private(text), pdf_part(10.0, 86.0), vec![], false, true, 1.0);
let link = |d: &Document| match d.symbols.first().and_then(|s| s.art.appearance.fill()).map(|f| &f.paint) {
Some(vectorcraft_color::Paint::Solid { swatch, .. }) => swatch.clone(),
_ => None,
};
let ink = |d: &Document, name: &str| d.swatch(name).map(|s| (s.paint.color(), s.spot));
let yellow = Some(vectorcraft_color::Color::cmyk(0.0, 0.0, 1.0, 0.0));
let (d, warnings, _) = open(&library("", "Brand Ink"));
assert_eq!(link(&d).as_deref(), Some("Brand Ink"), "{warnings:?}");
assert_eq!(ink(&d, "Brand Ink"), Some((yellow, true)));
let palette = "%AI5_BeginPalette\n0 0 Pb\n0 0 0 0 0 1 0 Xa\n(Clash)\nPc\nPB\n%AI5_EndPalette\n";
let (d, warnings, _) = open(&library(palette, "Clash"));
assert_eq!(link(&d).as_deref(), Some("Clash 2"), "{warnings:?}");
assert_eq!(ink(&d, "Clash 2"), Some((yellow, true)));
assert_eq!(ink(&d, "Clash"), Some((Some(vectorcraft_color::Color::rgb(0.0, 1.0, 0.0)), false)));
let (d, warnings, _) = open(&library("", "Red"));
assert_eq!(link(&d).as_deref(), Some("Red"), "{warnings:?}");
assert_eq!(ink(&d, "Red"), Some((yellow, true)));
assert_eq!(d.swatches.iter().filter(|s| s.name == "Red").count(), 1);
// An ink of the PDF part keeps its swatch: the library's color of that name is renamed.
let mut part = pdf_part(10.0, 86.0);
let green = vectorcraft_color::Paint::solid(vectorcraft_color::Color::cmyk(1.0, 0.0, 1.0, 0.0));
part.swatches.push(vectorcraft_color::Swatch { name: "Ink".into(), paint: green.clone(), global: true, spot: true });
let (d, warnings, _) = crate::layered_ai(&private(&library("", "Ink")), part, vec![], false, true, 1.0);
assert_eq!(link(&d).as_deref(), Some("Ink 2"), "{warnings:?}");
assert_eq!(ink(&d, "Ink 2"), Some((yellow, true)));
assert_eq!(d.swatch("Ink").map(|s| &s.paint), Some(&green));
}
/// A symbol library's symbols bring a global process color their art is filled with as a global
/// swatch that isn't an ink, and a spot color a stop of their gradient names as an ink.
#[test]
fn an_ai_symbol_librarys_symbols_keep_their_global_and_gradient_stop_colors() {
let gradient = "%AI5_BeginGradient: (Fade)\n(Fade) 0 2 Bd\n[\n\
%_0 1 1 0 (Brand) 0 0 5 1 6 50 0 Bs\n%_0 0 0 0 1 0 0 2 1 6 50 100 Bs\nBD\n%AI5_EndGradient\n";
let global = "0 0 1 0 (Process Yellow) 0 0 Xk\n-2 -2 m\n-2 2 L\n2 2 L\n2 -2 L\n-2 -2 L\nf\n";
let graded = "Bb\n1 (Fade) 0 0 0 4 1 0 0 1 0 0 Bg\n-2 -2 m\n-2 2 L\n2 2 L\n2 -2 L\n-2 -2 L\nf\n0 BB\n";
let defs = symbol_def("Global", global, 5) + &symbol_def("Graded", graded, 5);
let text = format!(
"%!PS-Adobe-3.0 \n%%BoundingBox: 0 0 100 100\n%%BeginSetup\n{gradient}%AI5_Begin_NonPrinting\n{defs}%AI5_End_NonPrinting--\n\
%%EndSetup\n%%PageTrailer\n%%Trailer\n"
);
let (d, warnings, _) = crate::layered_ai(&private(&text), pdf_part(10.0, 86.0), vec![], false, true, 1.0);
assert_eq!(symbol_names(&d), ["Global", "Graded"], "{warnings:?}");
let swatch = |name: &str| d.swatch(name).map(|s| (s.paint.color(), s.global, s.spot));
assert_eq!(swatch("Process Yellow"), Some((Some(vectorcraft_color::Color::cmyk(0.0, 0.0, 1.0, 0.0)), true, false)), "{warnings:?}");
assert_eq!(swatch("Brand"), Some((Some(vectorcraft_color::Color::cmyk(0.0, 1.0, 1.0, 0.0)), true, true)), "{warnings:?}");
}
/// A symbol library's symbol shows its image from the document's images, and an object of a
/// symbol's art linked to a style of the library's style list links to that style as the document
/// has it.
#[test]
fn an_ai_symbol_librarys_symbols_bring_their_images_and_style_links() {
// The template box's center is (100.5, 50.5): art space's origin is at canvas (8091, 8242).
let m = "[ 5 0 0 5 -8096 8244.5 ]";
let raster = format!(
"%AI5_File:\n%AI5_BeginRaster\n() 1 XG\n/DeviceRGB XN\n{m} 2 1 0 Xh\n{m} 0 0 2 1 2 1 8 3 0 0 1 0 4 4 0 0\n\
%%BeginData: 6\rXI\nABCDEF%%EndData\r\nXH\r\n%AI5_EndRaster\r\nN\n"
);
let path = "-2 -2 m\n-2 2 L\n2 2 L\n2 -2 L\n-2 -2 L\n";
let hidden: String = path.lines().map(|l| format!("%_{l}\n")).collect();
let styled = format!("0 Ae\nu\n0 0 0 0 0 0 1 XA\n0 J 0 j 3 w 10 M []0 d\n{path}S\nU\n{hidden}%_S\n1 (Thick) XW\n");
let defs = format!("%AI5_Begin_NonPrinting\n{}{}%AI5_End_NonPrinting--\n", symbol_def("Pic", &raster, 5), symbol_def("Line", &styled, 5));
let text = style_library(&defs).replacen("%%BeginSetup", "%AI3_TemplateBox: 100.5 50.5 100.5 50.5\n%%BeginSetup", 1);
let (d, warnings, read) = crate::layered_ai(&private(&text), pdf_part(10.0, 86.0), vec![], false, true, 1.0);
assert!(!read, "{warnings:?}");
assert_eq!(symbol_names(&d), ["Pic", "Line"], "{warnings:?}");
let key = d.symbols.first().and_then(|s| if let NodeKind::Image(im) = &s.art.kind { Some(im.key.clone()) } else { None });
let key = key.unwrap_or_else(|| panic!("an image: {:#?}", d.symbols.first()));
assert!(d.images.contains_key(&key), "{key}");
let mut linked = vec![];
let mut stack: Vec<&Node> = d.symbols.get(1).map(|s| &*s.art).into_iter().collect();
while let Some(n) = stack.pop() {
linked.extend(n.extras().graphic_style);
stack.extend(n.children().into_iter().flatten().map(|c| &**c));
}
let named: Vec<&str> = linked.iter().filter_map(|id| d.graphic_styles.iter().find(|g| g.id == *id)).map(|g| g.name.as_str()).collect();
assert_eq!(named, ["Thick"], "{linked:?}");
}
/// The instances of a symbol library's symbols that would draw more than
/// [`vectorcraft_doc::depth::MAX_DRAWN_DEPTH`] objects deep go, with the note saying so, and a
/// document that has symbols already keeps them.
#[test]
fn an_ai_symbol_librarys_instances_drawn_too_deep_go() {
// C0 is a square, and each later symbol holds an instance of the one before it. The template
// box's center is (100.5, 50.5): art space's origin is at canvas (8091, 8242).
let instance = |name: &str| format!("/SymbolInstance :\n({name}) /SymbolRef ,\n1 0 0 -1 -8091 8242 /RTransformMatrix\n;\n9 () XW\n");
let count = vectorcraft_doc::depth::MAX_DRAWN_DEPTH + 10;
let mut defs = symbol_def("C0", &symbol_square(-2.0, -2.0, 2.0, 2.0), 5);
for i in 1..count {
defs.push_str(&symbol_def(&format!("C{i}"), &instance(&format!("C{}", i - 1)), 5));
}
let text = format!(
"%!PS-Adobe-3.0 \n%%BoundingBox: 0 0 100 100\n%AI3_TemplateBox: 100.5 50.5 100.5 50.5\n%%BeginSetup\n\
%AI5_Begin_NonPrinting\n{defs}%AI5_End_NonPrinting--\n%%EndSetup\n%%PageTrailer\n%%Trailer\n"
);
let (d, warnings, _) = crate::layered_ai(&private(&text), pdf_part(10.0, 86.0), vec![], false, true, 1.0);
assert_eq!(d.symbols.len(), count, "{warnings:?}");
let instances = d.symbols.iter().filter(|s| matches!(s.art.kind, NodeKind::SymbolInstance { .. })).count();
assert!(instances < count - 1, "{instances}");
assert!(warnings.contains(&vectorcraft_doc::depth::symbols_note()), "{warnings:?}");
// A document with symbols keeps its own.
let mut part = pdf_part(10.0, 86.0);
let mine = Node::group(part.alloc_id(), vec![]);
part.symbols.push(vectorcraft_doc::Symbol { name: "Mine".into(), art: std::sync::Arc::new(mine), dynamic: false });
let (d, warnings, _) = crate::layered_ai(&private(&text), part, vec![], false, true, 1.0);
assert_eq!(symbol_names(&d), ["Mine"], "{warnings:?}");
}
/// A PDF part whose tiling has the name of a pattern its editing data defines (the PDF part names
/// its tilings `Pattern 1`, `Pattern 2` and so on): the editing data's pattern comes in under a free
/// variant of the name, and the palette's swatch and the brush's art paint with it, not with the
File diff suppressed because one or more lines are too long
+3 -1
View File
@@ -2378,7 +2378,9 @@ what dragging a symbol out of the library panel onto the canvas does.
`symbol.saveLibrary {path?, names?, name?, user?}` writes the document's symbols as a symbol library: a `.vectorcraft`
document holding only them and what they use; without `path` it returns `{dataBase64}`, and `user: true` saves into
the user library folder (category `user`, User Defined). `symbol.loadLibrary {path? | data? | dataBase64?, name?}`
loads the symbols of any document VectorCraft opens as a library to add from; a file it can't read is an error.
loads the symbols of any document VectorCraft opens as a library to add from (a `.ai` or EPS whose editing data holds
symbols and no layers gives the symbols it defines, in the order of its symbol list); a file it can't read is an
error.
## Brush libraries
+1
View File
@@ -1222,6 +1222,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
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`).
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`).
A `.ai` or EPS opened from its editing data whose text document makes the type of every text object that shows takes all its type from the text document: each text object stays in its own group, frame and layer, the page's type isn't matched with them, a file of more than 5,000 text objects still opens with its layers, and type the page draws differently (in another font) keeps the layers, with a warning. A line break inside a paragraph stays a line break in it (`crates/eps/src/import/tests_native.rs`, `crates/eps/src/import/ate.rs`).
In SVG export without Fewer `<tspan>` Elements, each character of live type that justification or Mojikumi moves (the letter gaps of a Justify All line without word spaces, the gaps between the characters of a justified Japanese line, closed-up punctuation, the space between Japanese and Latin letters) starts its own positioned `<tspan>`, and type scaled horizontally on a justified line is stretched to its own width (`crates/svg/tests/it/text_layout.rs`).
To find those characters, SVG export lays a type object out a second time only when the second layout can differ from the first: point type with Line-end Punctuation Half Width and no Japanese punctuation or letters, the setting new type gets, is laid out once. Exporting 5,000 such objects takes a median of 109.4 ms instead of 171.5 ms on Windows 11, with the same SVG (`crates/svg/src/export/text/tests.rs`).