Merge main into fix/the-liquify-warning-s-tool-name-and-object-kinds

This commit is contained in:
dotCooCoo
2026-11-15 07:54:14 -08:00
11 changed files with 404 additions and 47 deletions
+92 -14
View File
@@ -4108,20 +4108,21 @@ fn predefined_mojikumi_sets_are_reported_as_left_out() {
}
}
/// The text document has no Bunri-Kinshi: a paragraph with it on and an inseparable pair in it is
/// reported as left out, and comes back off; with it off, or with no pair, nothing is reported.
/// Bunri-Kinshi comes back on or off, with or without an inseparable pair in the paragraph, and
/// nothing is reported.
#[test]
fn bunri_kinshi_is_reported_only_for_paragraphs_with_a_pair() {
fn bunri_kinshi_comes_back_with_or_without_a_pair() {
use vectorcraft_doc::TextObject;
for (text, on, reported) in [
("Wait——now", true, true),
("Wait——now", false, false),
("Wait—now", true, false),
("Wait……now", true, true),
("Wait‥‥now", true, true),
("あ〳〵い", true, true),
("あ〴〵い", true, true),
("あ〵〳い", true, false),
for (text, on) in [
("Wait——now", true),
("Wait——now", false),
("Wait—now", true),
("Wait……now", true),
("Wait‥‥now", true),
("あ〳〵い", true),
("あ〴〵い", true),
("あ〵〳い", true),
("あ〵〳い", false),
] {
let mut t = TextObject::point(vectorcraft_geom::Point::new(20.0, 40.0), text, style(14.0, Color::BLACK));
t.para.bunri_kinshi = on;
@@ -4130,7 +4131,7 @@ fn bunri_kinshi_is_reported_only_for_paragraphs_with_a_pair() {
let n = text_node(&mut doc, t);
doc.insert(Some(layer), usize::MAX, n).unwrap();
let out = export_ai_editing(&doc, &opts()).unwrap();
assert_eq!(!out.warnings.is_empty(), reported, "{text} {on}: {:?}", out.warnings);
assert!(out.warnings.is_empty(), "{text} {on}: {:?}", out.warnings);
let mut all = vec![];
paths(&read_back(&doc).layers, &mut all);
let paras: Vec<bool> = all
@@ -4140,10 +4141,87 @@ fn bunri_kinshi_is_reported_only_for_paragraphs_with_a_pair() {
_ => None,
})
.collect();
assert_eq!(paras, [false], "{text} {on}");
assert_eq!(paras, [on], "{text} {on}");
}
}
/// Each paragraph's Kinsoku set, Kinsoku Shori Type, Burasagari and Bunri-Kinshi come back, and
/// nothing is reported: every value of each, mixed across the paragraphs of one object, Burasagari
/// and Bunri-Kinshi kept under Kinsoku None. The text document lists the Hard and Soft sets, and
/// every paragraph, the normal paragraph style and the document's defaults write all four keys.
/// Another attribute the text document leaves out is still reported.
#[test]
fn kinsoku_settings_come_back_on_each_paragraph() {
use vectorcraft_doc::{Burasagari, Kinsoku, KinsokuShoriType, ParaStyle, TextObject};
let cases = [
(Kinsoku::None, KinsokuShoriType::PushInFirst, Burasagari::Forced, true),
(Kinsoku::Soft, KinsokuShoriType::PushOutFirst, Burasagari::Standard, false),
(Kinsoku::Hard, KinsokuShoriType::PushOutOnly, Burasagari::None, true),
(Kinsoku::Hard, KinsokuShoriType::PushInFirst, Burasagari::Standard, false),
(Kinsoku::Soft, KinsokuShoriType::PushOutOnly, Burasagari::Forced, true),
];
let mut t = TextObject::point(vectorcraft_geom::Point::new(20.0, 40.0), "かな。\n「かな」、\nあ——い\nかな\nかな。", style(14.0, Color::BLACK));
t.set_paragraph_styles(
cases
.iter()
.map(|&(kinsoku, kinsoku_type, burasagari, bunri_kinshi)| ParaStyle {
kinsoku,
kinsoku_type,
burasagari,
bunri_kinshi,
..ParaStyle::default()
})
.collect(),
);
let mut doc = Document::new(200.0, 200.0);
let layer = doc.layers[0].id;
let n = text_node(&mut doc, t);
doc.insert(Some(layer), usize::MAX, n).unwrap();
let out = export_ai_editing(&doc, &opts()).unwrap();
assert!(out.warnings.is_empty(), "{:?}", out.warnings);
let back = read_back(&doc);
same_lines(&type_lines(&back), &type_lines(&doc));
let mut all = vec![];
paths(&back.layers, &mut all);
let read: Vec<_> = all
.iter()
.filter_map(|n| match &n.kind {
NodeKind::Text(t) => {
Some(t.paragraph_styles().iter().map(|p| (p.kinsoku, p.kinsoku_type, p.burasagari, p.bunri_kinshi)).collect::<Vec<_>>())
}
_ => None,
})
.collect();
assert_eq!(read, [cases.to_vec()]);
let decoded = text_document(&program(&doc));
let hard = decoded.find("PhotoshopKinsokuHard").unwrap_or_else(|| panic!("{decoded}"));
let soft = decoded.find("PhotoshopKinsokuSoft").unwrap_or_else(|| panic!("{decoded}"));
assert!(hard < soft, "{decoded}");
// Five paragraphs, then the normal paragraph style and the document's defaults (Hard, Push Out
// Only, no Burasagari, Bunri-Kinshi off).
for (key, count) in [
("/27 /nil", 1),
("/27 0", 4),
("/27 1", 2),
("/25 0", 2),
("/25 1", 1),
("/25 2", 4),
("/24 0", 3),
("/24 1", 2),
("/24 2", 2),
("/23 true", 3),
("/23 false", 4),
] {
assert_eq!(decoded.matches(key).count(), count, "{key}: {decoded}");
}
let mut lossy = doc.clone();
let id = lossy.layers[0].children().unwrap()[0].id;
if let Some(NodeKind::Text(t)) = lossy.node_mut(id).map(|n| &mut n.kind) {
t.runs[0].style.underline = true;
}
assert_eq!(export_ai_editing(&lossy, &opts()).unwrap().warnings, [writer::TYPE_ATTRIBUTES]);
}
#[test]
fn type_is_written_again_as_the_same_bytes() {
let doc = typed();
+40 -11
View File
@@ -22,15 +22,15 @@ use kurbo::{ParamCurveArclen, PathSeg};
use vectorcraft_color::{Color, Paint};
use vectorcraft_doc::text::MAX_AKI;
use vectorcraft_doc::{
AreaOptions, Burasagari, CharStyle, Document, FirstBaseline, Justify, LineCap, LineJoin, Mojikumi, Node, NodeId, NodeKind, ParaDirection,
ParaStyle, PathAlign, PathEffect, TextKind, TextObject, VerticalAlign,
AreaOptions, Burasagari, CharStyle, Document, FirstBaseline, Justify, Kinsoku, KinsokuShoriType, LineCap, LineJoin, Mojikumi, Node, NodeId,
NodeKind, ParaDirection, ParaStyle, PathAlign, PathEffect, TextKind, TextObject, VerticalAlign,
};
use vectorcraft_geom::{Affine, PathData, Point};
use crate::ps;
/// What the text document holds of type, and what it leaves out.
pub(in crate::ai_editing) const TYPE_ATTRIBUTES: &str = "attributes of type other than its font, size, leading, tracking, baseline shift, horizontal and vertical scale, solid fill, solid stroke and its weight, cap, join and miter limit, capitals, small capitals at the document's size, Tate-chu-yoko, Standard Vertical Roman Alignment, Insert Aki, paragraph alignment, indents, space before and after, hyphenation on or off and right-to-left direction (for example underline, kerning, OpenType features, swatch links of its colors, character and paragraph styles, tabs, lists, optical margin alignment, area type's inset spacing, vertical alignment and flow, a minimum first baseline with the Ascent first baseline, and type on a path's effect, alignment and spacing and an end bracket at the very end of an open path) are left out of the editing data for other apps";
pub(in crate::ai_editing) const TYPE_ATTRIBUTES: &str = "attributes of type other than its font, size, leading, tracking, baseline shift, horizontal and vertical scale, solid fill, solid stroke and its weight, cap, join and miter limit, capitals, small capitals at the document's size, Tate-chu-yoko, Standard Vertical Roman Alignment, Insert Aki, paragraph alignment, indents, space before and after, hyphenation on or off, right-to-left direction, Kinsoku set, Kinsoku Shori Type, Burasagari and Bunri-Kinshi (for example underline, kerning, OpenType features, swatch links of its colors, character and paragraph styles, tabs, lists, optical margin alignment, area type's inset spacing, vertical alignment and flow, a minimum first baseline with the Ascent first baseline, and type on a path's effect, alignment and spacing and an end bracket at the very end of an open path) are left out of the editing data for other apps";
/// The version of the text document's form (`/98 << /0 n >>`), as the newest files users sent have it.
const STREAM_VERSION: u32 = 14;
@@ -161,6 +161,10 @@ fn dict(pairs: Vec<(u32, V)>) -> V {
V::Dict(pairs)
}
/// The document's Kinsoku sets, in order, each by its name: a paragraph's key 27 is its set's index
/// here (0 Hard, 1 Soft), as the reader's `kinsoku_sets` reads them.
const KINSOKU_SETS: [&str; 2] = ["PhotoshopKinsokuHard", "PhotoshopKinsokuSoft"];
/// A resource set: its resources, each `<< /0 resource >>`, and its display list.
fn set(resources: Vec<V>, display: bool) -> V {
let mut d = vec![(0, V::List(resources.into_iter().map(|r| dict(vec![(0, r)])).collect()))];
@@ -401,7 +405,6 @@ pub(in crate::ai_editing) fn loses(t: &TextObject) -> bool {
}
let hangul =
text.chars().any(|c| matches!(c, '\u{1100}'..='\u{11FF}' | '\u{3130}'..='\u{318F}' | '\u{A960}'..='\u{A97F}' | '\u{AC00}'..='\u{D7FF}' | '\u{FFA0}'..='\u{FFDC}'));
let pairs = text.chars().zip(text.chars().skip(1)).any(|(a, b)| vectorcraft_text::inseparable(a, b));
let held = ParaStyle {
justify: p.justify,
left_indent: p.left_indent,
@@ -411,16 +414,16 @@ pub(in crate::ai_editing) fn loses(t: &TextObject) -> bool {
space_after: p.space_after,
hyphenate: p.hyphenate,
direction: p.direction.filter(|d| *d == ParaDirection::RightToLeft),
// The composition of Japanese punctuation new type gets (Line-end Punctuation Half
// Width, Standard burasagari) isn't reported: it changes no other script's lines.
// The Mojikumi set new type gets (Line-end Punctuation Half Width) isn't reported: it
// changes no other script's lines.
mojikumi: if p.mojikumi == Mojikumi::LineEndHalf { p.mojikumi } else { ParaStyle::default().mojikumi },
burasagari: if p.burasagari == Burasagari::Standard { p.burasagari } else { ParaStyle::default().burasagari },
kinsoku: p.kinsoku,
kinsoku_type: p.kinsoku_type,
burasagari: p.burasagari,
bunri_kinshi: p.bunri_kinshi,
// The text document has no Korean Line Break Anywhere: it reads back off, which
// changes only the lines of a paragraph with Hangul in it.
korean_line_break_anywhere: p.korean_line_break_anywhere && !hangul,
// Nor Bunri-Kinshi: it reads back off, which changes only the lines of a paragraph
// with an inseparable pair in it.
bunri_kinshi: p.bunri_kinshi && !pairs,
..ParaStyle::default()
};
*p != held
@@ -756,6 +759,32 @@ impl TextDoc {
(4, len(p.space_before)),
(5, len(p.space_after)),
(9, V::Bool(p.hyphenate)),
(23, V::Bool(p.bunri_kinshi)),
(
24,
V::Int(match p.burasagari {
Burasagari::None => 0,
Burasagari::Standard => 1,
Burasagari::Forced => 2,
}),
),
(
25,
V::Int(match p.kinsoku_type {
KinsokuShoriType::PushInFirst => 0,
KinsokuShoriType::PushOutFirst => 1,
KinsokuShoriType::PushOutOnly => 2,
}),
),
// The Kinsoku set: `/nil` for None, else its index in the document's sets ([`KINSOKU_SETS`]).
(
27,
match p.kinsoku {
Kinsoku::None => V::Name("nil"),
Kinsoku::Hard => V::Int(0),
Kinsoku::Soft => V::Int(1),
},
),
];
if rtl {
d.push((33, V::Int(1)));
@@ -1110,7 +1139,7 @@ impl TextDoc {
(1, set(fonts, true)),
(2, empty()),
(3, empty()),
(4, empty()),
(4, set(KINSOKU_SETS.iter().map(|name| dict(vec![(0, V::Str((*name).into()))])).collect(), false)),
(5, set(vec![normal_char], true)),
(6, set(vec![normal_para], true)),
(8, set(self.frames.iter().map(clone_v).collect(), false)),
+5
View File
@@ -581,6 +581,10 @@ struct Reader<'a> {
blend_budget: usize,
/// The group on `%_` lines an envelope's dictionary just took (see [`Reader::drop_envelope_art`]).
envelope_art: Option<Node>,
/// The envelope dictionaries whose `AIDeformArtKey` block (`X=` … `X+`) is being read, as how
/// many frames were open with each one innermost, innermost last. The block's art is art: a
/// dictionary in it is read as it is in a container ([`Reader::end_obj`]).
envelope_blocks: Vec<usize>,
/// Envelopes waiting for their drawn art, innermost last.
envelopes: Vec<PendingEnvelope>,
/// How many more envelopes and warped text objects this import may draw to check
@@ -813,6 +817,7 @@ impl<'a> Reader<'a> {
blend_record: None,
blend_budget: BLEND_BUDGET,
envelope_art: None,
envelope_blocks: Vec::new(),
envelopes: Vec::new(),
envelope_checks: super::envelope::MAX_CHECKED,
envelope_spent: super::envelope::Spent::default(),
+11 -1
View File
@@ -482,6 +482,13 @@ impl<'a> Reader<'a> {
return Ok(());
}
let Some(f) = self.frames.pop() else { return Ok(()) };
let depth = self.frames.len();
// A block left open ends with its dictionary, and envelopes still waiting in it keep their
// drawn art: nothing after the dictionary is theirs.
self.envelope_blocks.retain(|d| *d <= depth);
while let Some(p) = self.envelopes.pop_if(|p| p.depth > depth) {
self.warn(crate::import::ai::envelope::drawn_note(p.typed));
}
let Frame { kind, children, base, hidden, gs, pending_unread_fill, pending_unread_stroke, after, mesh_ended, state, .. } = f;
let Kind::Obj(mut o) = kind else { return Ok(()) };
obj::close(&mut o, &mut self.stack, base);
@@ -496,7 +503,10 @@ impl<'a> Reader<'a> {
}
self.after_object = after;
self.mesh_ended = mesh_ended;
if matches!(self.frames.last(), Some(Frame { kind: Kind::Obj(_), .. })) {
// An object's dictionary in an envelope's `AIDeformArtKey` block is about the art before it
// there, as it is in a container: an envelope there is one of the outer envelope's contents.
let in_block = o.ty == "ArtDictionary" && self.envelope_blocks.last() == Some(&depth);
if !in_block && matches!(self.frames.last(), Some(Frame { kind: Kind::Obj(_), .. })) {
return self.push(V::Obj(Rc::new(*o)));
}
match o.ty.as_str() {
+29 -3
View File
@@ -41,8 +41,19 @@ impl<'a> Reader<'a> {
}
/// `X=` in a `/Mask` dictionary: the opacity mask's art starts, read until its `X+`
/// ([`Self::end_mask`]).
/// ([`Self::end_mask`]). In an envelope's dictionary, its `AIDeformArtKey` block starts
/// ([`Reader::envelope_blocks`]).
fn open_mask_object(&mut self, hidden: bool) -> Result<(), String> {
if let Some(Frame { kind: Kind::Obj(o), .. }) = self.frames.last()
&& o.ty == "ArtDictionary"
&& o.get("AIDeformOptionsKey").is_some()
{
// One entry for each open dictionary, however many `X=` it has.
if self.envelope_blocks.last() != Some(&self.frames.len()) {
self.envelope_blocks.push(self.frames.len());
}
return Ok(());
}
if !matches!(self.frames.last(), Some(Frame { kind: Kind::Obj(o), .. }) if o.ty == "Mask") {
// `X=` also introduces legacy text frame art, read by `text_frames`.
return Ok(());
@@ -63,6 +74,22 @@ impl<'a> Reader<'a> {
self.open(Kind::Mask, hidden)
}
/// `X+`: a dictionary's art block ends. The block of a dictionary whose `X=` opened no frame (an
/// envelope's, in an opacity mask's art too) ends with the dictionary still innermost; an opacity
/// mask's ends its art ([`Self::end_mask`]).
fn end_block(&mut self) -> Result<(), String> {
if matches!(self.frames.last(), Some(Frame { kind: Kind::Obj(_), .. })) {
if self.envelope_blocks.last() == Some(&self.frames.len()) {
self.envelope_blocks.pop();
}
return Ok(());
}
if self.frames.iter().any(|f| matches!(f.kind, Kind::Mask)) {
return self.end_mask();
}
Ok(())
}
/// `LB`: a graph started in this layer that hasn't ended doesn't go on past it; the layer ends.
fn layer_end(&mut self) -> Result<(), String> {
if self.graph.as_ref().is_some_and(|g| g.frames >= self.frames.len()) {
@@ -159,8 +186,7 @@ impl<'a> Reader<'a> {
}
";" => return self.end_obj(),
"X=" => return self.open_mask_object(hidden),
"X+" if self.frames.iter().any(|f| matches!(f.kind, Kind::Mask)) => return self.end_mask(),
"X+" => return Ok(()),
"X+" => return self.end_block(),
_ => {}
}
self.state_block_continues(w);
+218
View File
@@ -8620,6 +8620,224 @@ fn an_envelope_off_the_page_opens_live_when_it_draws_close_to_its_drawn_art() {
assert!(r.warnings.is_empty(), "{:?}", r.warnings);
}
/// `art` on `%_` lines, as the editing data writer hides it: a line already on one stays as it is.
fn hidden_once(art: &str) -> String {
art.lines().map(|l| if l.starts_with("%_") { format!("{l}\n") } else { format!("%_{l}\n") }).collect()
}
/// A mesh envelope of `content` shaped by the grid `shape`, with Edit Contents on (`editing`: the
/// contents in the group before the dictionary, the grid in its `AIDeformArtKey` block) or off (the
/// other way round, the contents in a plain group), then `drawn` and the plugin's `XP`. An envelope
/// record in `content` keeps its own `%_` lines.
fn mesh_envelope(shape: &str, editing: bool, content: &str, drawn: &str) -> String {
let keys = ENVELOPE_KEYS.replace("0 /Bool (AIDeformEditModeKey)", &format!("{} /Bool (AIDeformEditModeKey)", u8::from(editing)));
let (before, block) = if editing { (content.to_string(), shape.to_string()) } else { (shape.to_string(), format!("u\n{content}U\n9 () XW\n")) };
format!(
"{}%_/ArtDictionary :\n{}%_X=\n{}%_X+\n%_ (AIDeformArtKey) ,\n%_2 /Int (AIDeformStyle) ,\n%_;\n%_\n%_9 () XW\nu\n{drawn}U\n9 () XW\n(Adobe Deform Plugin) 1 0 0 XP\n",
hidden_once(&format!("u\n{before}U\n")),
commented(&keys),
hidden_once(&block),
)
}
/// The mesh envelope that maps the box 40 20 160 80 onto itself, and what it draws of
/// [`envelope_content`].
fn flat_mesh() -> (String, vectorcraft_doc::live::EnvelopeKind, String) {
let flat = vectorcraft_doc::live::EnvelopeKind::Mesh {
rows: 1,
cols: 1,
points: vec![Point::new(40.0, 20.0), Point::new(160.0, 20.0), Point::new(40.0, 80.0), Point::new(160.0, 80.0)],
handles: vec![],
};
let drawn = drawn_content(&flat);
(straight_mesh(1, 1, (120.0, 60.0)), flat, drawn)
}
/// An envelope inside another envelope's contents opens as a live envelope inside the live outer
/// one, with Edit Contents on or off at either level: each keeps its own kind, contents and Edit
/// Contents, and neither leaves a copy of its contents drawn beside it.
#[test]
fn an_envelope_in_an_envelope_s_contents_opens_live_inside_it() {
use vectorcraft_doc::live::EnvelopeKind;
let (shape, flat, drawn) = flat_mesh();
let EnvelopeKind::Mesh { points, .. } = &flat else { panic!("{flat:?}") };
for (outer_editing, inner_editing) in [(false, false), (false, true), (true, false), (true, true)] {
let why = format!("outer editing {outer_editing}, inner editing {inner_editing}");
let inner = mesh_envelope(&shape, inner_editing, &envelope_content(), &drawn);
let r = read_ok(&layer(&mesh_envelope(&shape, outer_editing, &hidden_once(&inner), &format!("u\n{drawn}U\n"))));
let a = art(&r.doc);
assert_eq!(a.len(), 1, "{why}: {a:#?}");
let flat_points = |kind: &EnvelopeKind| match kind {
EnvelopeKind::Mesh { rows: 1, cols: 1, points, .. } => Some(points.clone()),
_ => None,
};
let (content, kind, _, editing, _) = live_envelope(&a[0]);
assert_eq!((flat_points(kind), editing), (Some(points.clone()), outer_editing), "{why}: {kind:?}");
assert_eq!(content.len(), 1, "{why}: {content:#?}");
let (inner, kind, _, editing, _) = live_envelope(&content[0]);
assert_eq!((flat_points(kind), editing), (Some(points.clone()), inner_editing), "{why}: {kind:?}");
assert_eq!(inner.len(), 1, "{why}: {inner:#?}");
assert!(matches!(inner[0].kind, NodeKind::Path { .. }), "{why}: {inner:#?}");
assert_eq!(fill(&inner[0]).color(), Some(Color::rgb(1.0, 0.0, 0.0)), "{why}");
assert!(r.warnings.is_empty(), "{why}: {:?}", r.warnings);
}
}
/// An outer envelope, Edit Contents off, whose `AIDeformArtKey` block holds `block` as it is, with no
/// plain group around it, shaped by the grid `shape` and drawn as `drawn`.
fn bare_block_envelope(shape: &str, block: &str, drawn: &str) -> String {
format!(
"{}%_/ArtDictionary :\n{}%_X=\n{}%_X+\n%_ (AIDeformArtKey) ,\n%_2 /Int (AIDeformStyle) ,\n%_;\n%_\n%_9 () XW\nu\n{drawn}U\n9 () XW\n(Adobe Deform Plugin) 1 0 0 XP\n",
hidden_once(&format!("u\n{shape}U\n")),
commented(ENVELOPE_KEYS),
hidden_once(block),
)
}
/// An envelope record straight in another envelope's `AIDeformArtKey` block, with no group around
/// it, opens live inside the live outer envelope too. Two of them there are both its contents.
#[test]
fn an_envelope_straight_in_an_envelope_s_block_opens_live_inside_it() {
let (shape, _, drawn) = flat_mesh();
let inner = hidden_once(&mesh_envelope(&shape, false, &envelope_content(), &drawn));
let r = read_ok(&layer(&bare_block_envelope(&shape, &inner, &format!("u\n{drawn}U\n"))));
let a = art(&r.doc);
assert_eq!(a.len(), 1, "{a:#?}");
let (content, ..) = live_envelope(&a[0]);
assert_eq!(content.len(), 1, "{content:#?}");
let (inner_content, ..) = live_envelope(&content[0]);
assert!(matches!(inner_content[0].kind, NodeKind::Path { .. }), "{inner_content:#?}");
assert!(r.warnings.is_empty(), "{:?}", r.warnings);
// Two envelopes side by side in the block: both are the outer envelope's contents, each live.
let two = format!("{inner}{inner}");
let r = read_ok(&layer(&bare_block_envelope(&shape, &two, &format!("u\n{drawn}U\nu\n{drawn}U\n"))));
let a = art(&r.doc);
assert_eq!(a.len(), 1, "{a:#?}");
let (content, ..) = live_envelope(&a[0]);
assert_eq!(content.len(), 2, "{content:#?}");
content.iter().for_each(|c| _ = live_envelope(c));
assert!(r.warnings.is_empty(), "{:?}", r.warnings);
}
/// An object's own dictionary straight in an envelope's block, with no group around them, names it
/// there.
#[test]
fn an_object_s_dictionary_straight_in_an_envelope_s_block_names_it() {
let (shape, _, drawn) = flat_mesh();
let block = format!("{}/ArtDictionary :\n(Box) /String (AIArtName) ,\n;\n", envelope_content());
let r = read_ok(&layer(&bare_block_envelope(&shape, &block, &format!("u\n{drawn}U\n"))));
let a = art(&r.doc);
assert_eq!(a.len(), 1, "{a:#?}");
let (content, ..) = live_envelope(&a[0]);
assert_eq!(content.len(), 1, "{content:#?}");
assert_eq!(content[0].name.as_deref(), Some("Box"), "{content:#?}");
}
/// An inner envelope that doesn't open live keeps its drawn art inside the live outer envelope,
/// drawn once, without its own source art: one whose drawn art differs from what it draws, and one
/// whose record doesn't read (a style number past the list). The outer envelope maps that drawn
/// art's box onto its grid. An outer envelope that doesn't match its drawn art keeps that drawn
/// art, and nothing of its record is drawn.
#[test]
fn a_nested_envelope_that_doesn_t_open_live_keeps_its_drawn_art() {
let (shape, _, drawn) = flat_mesh();
let shifted = format!("{RED}{}f\n", rect_path(42.0, 20.0, 162.0, 80.0));
let unread = mesh_envelope(&shape, false, &envelope_content(), &drawn).replace("%_2 /Int (AIDeformStyle)", "%_9 /Int (AIDeformStyle)");
for (why, inner) in [("drawn elsewhere", mesh_envelope(&shape, false, &envelope_content(), &shifted)), ("unread", unread)] {
for bare in [false, true] {
let inner = hidden_once(&inner);
let outer_drawn = format!("u\n{drawn}U\n");
let body = if bare { bare_block_envelope(&shape, &inner, &outer_drawn) } else { mesh_envelope(&shape, false, &inner, &outer_drawn) };
let r = read_ok(&layer(&body));
let a = art(&r.doc);
assert_eq!(a.len(), 1, "{why}, bare {bare}: {a:#?}");
assert!(matches!(a[0].kind, NodeKind::Envelope { .. }), "{why}, bare {bare}: {:?}", r.warnings);
let (content, ..) = live_envelope(&a[0]);
assert_eq!(content.len(), 1, "{why}, bare {bare}: {content:#?}");
// The inner envelope's drawn art: its group of one path, or, straight in the block, the
// path, as the plain group around a block's only object is the block's own.
let drawn_path = if bare {
&content[0]
} else {
let kids = content[0].children().unwrap_or_else(|| panic!("{why}: {content:#?}"));
assert_eq!(kids.len(), 1, "{why}: {content:#?}");
&kids[0]
};
assert!(matches!(drawn_path.kind, NodeKind::Path { .. }), "{why}, bare {bare}: {content:#?}");
assert_eq!(r.warnings, [super::envelope::DRAWN], "{why}, bare {bare}");
}
}
// The outer envelope's drawn art lies elsewhere: it stays, as one group, the inner record with it.
let inner = hidden_once(&mesh_envelope(&shape, false, &envelope_content(), &drawn));
for bare in [false, true] {
let outer_drawn = format!("u\n{shifted}U\n");
let body = if bare { bare_block_envelope(&shape, &inner, &outer_drawn) } else { mesh_envelope(&shape, false, &inner, &outer_drawn) };
let r = read_ok(&layer(&body));
let a = art(&r.doc);
assert_eq!(a.len(), 1, "bare {bare}: {a:#?}");
assert!(matches!(a[0].kind, NodeKind::Group { .. }), "bare {bare}: {a:#?}");
assert_eq!(a[0].geometric_bounds(), Some(Rect::new(42.0, 20.0, 162.0, 80.0)), "bare {bare}");
assert_eq!(r.warnings, [super::envelope::DRAWN], "bare {bare}");
}
}
/// Broken nested records read without taking another record's place: an inner `X=` with no `X+`
/// (the inner envelope still opens live), an inner dictionary with no group before it (its drawn art
/// stays), and an `XP` repeated after the inner one. The outer envelope, whose own record is whole,
/// still opens live around what the inner one left.
#[test]
fn broken_nested_envelope_records_keep_the_outer_envelope() {
let (shape, _, drawn) = flat_mesh();
let inner = hidden_once(&mesh_envelope(&shape, false, &envelope_content(), &drawn));
let no_end = inner.replacen("%_X+\n", "", 1);
let no_group = inner.replacen(&hidden_once(&format!("u\n{shape}U\n")), "", 1);
let twice = inner.replace("%_(Adobe Deform Plugin) 1 0 0 XP\n", "%_(Adobe Deform Plugin) 1 0 0 XP\n%_(Adobe Deform Plugin) 1 0 0 XP\n");
for (why, inner, live) in [("no X+", no_end, true), ("no group", no_group, false), ("XP twice", twice, true)] {
for bare in [false, true] {
let outer_drawn = format!("u\n{drawn}U\n");
let body = if bare { bare_block_envelope(&shape, &inner, &outer_drawn) } else { mesh_envelope(&shape, false, &inner, &outer_drawn) };
let r = read_ok(&layer(&body));
let a = art(&r.doc);
assert_eq!(a.len(), 1, "{why}, bare {bare}: {a:#?}");
let (content, ..) = live_envelope(&a[0]);
assert_eq!(content.len(), 1, "{why}, bare {bare}: {content:#?}");
assert_eq!(matches!(content[0].kind, NodeKind::Envelope { .. }), live, "{why}, bare {bare}: {content:#?}");
}
}
}
/// An inner envelope whose `XP` is missing stops waiting when the outer envelope's dictionary ends:
/// a stray `XP` in a later group leaves that group's art as it is.
#[test]
fn an_inner_envelope_without_its_xp_does_not_take_later_art() {
let (shape, _, drawn) = flat_mesh();
let inner = hidden_once(&mesh_envelope(&shape, false, &envelope_content(), &drawn)).replace("%_(Adobe Deform Plugin) 1 0 0 XP\n", "");
let later = format!("u\nu\n{drawn}U\n(Adobe Deform Plugin) 1 0 0 XP\nU\n");
let r = read_ok(&layer(&format!("{}{later}", bare_block_envelope(&shape, &inner, &format!("u\n{drawn}U\n")))));
let a = art(&r.doc);
assert_eq!(a.len(), 2, "{a:#?}");
live_envelope(&a[0]);
let kids = a[1].children().unwrap_or_else(|| panic!("{a:#?}"));
assert!(matches!(kids[0].kind, NodeKind::Group { .. }), "{a:#?}");
assert_eq!(r.warnings, [super::envelope::DRAWN], "{:?}", r.warnings);
}
/// An envelope in an opacity mask's art reads: its block's `X+` ends the block, not the mask's art.
#[test]
fn an_envelope_in_an_opacity_mask_s_art_reads() {
let (shape, _, drawn) = flat_mesh();
let owner = format!("{RED}{}f\n", rect_path(10.0, 20.0, 170.0, 90.0));
let envelope = hidden_once(&mesh_envelope(&shape, false, &envelope_content(), &drawn));
let mask = format!(
"%_/ArtDictionary :\n%_/Mask :\n%_1 /Bool (Linked) ,\n%_X=\n%_u\n{envelope}%_U\n%_X+\n%_(Art) ,\n%_1 /Bool (Clipping) ,\n%_0 /Bool (Inverted) ,\n%_0 /Bool (Disabled) ,\n%_; (AI9_Mask) ,\n%_;\n"
);
let r = read_ok(&layer(&format!("{owner}{mask}")));
let a = art(&r.doc);
assert_eq!(a.len(), 1, "{a:#?}");
let m = a[0].extras().mask.as_ref().unwrap_or_else(|| panic!("{a:#?}"));
assert_eq!(m.art.geometric_bounds(), Some(Rect::new(40.0, 20.0, 160.0, 80.0)), "{:#?}", m.art);
}
#[test]
fn a_gradient_mesh_reads_as_a_patch() {
let corner = |rgb: &str, x: i32, y: i32, next: (i32, i32), prev: (i32, i32)| {
-12
View File
@@ -6706,7 +6706,6 @@ font-technology Variable ცვლადი
@msg plug-in failed: {0} პლაგინის შეცდომა: {0}
@msg plug-in manifest: {0} პლაგინის მანიფესტი: {0}
@msg plug-in output: {0} პლაგინის შედეგი: {0}
@msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why}
@msg plug-in parameters: {0} პლაგინის პარამეტრები: {0}
@msg plug-in trapped: {0} პლაგინი ავარიულად შეჩერდა: {0}
@msg print settings are not an object ბეჭდვის პარამეტრები ობიექტი არ არის
@@ -7825,17 +7824,6 @@ liquify-list-end {0}, {1} {0} და {1}
@msg `name` must be the name of a script engine `name` უნდა იყოს სკრიპტის ძრავის სახელი
@msg the main script engine is new for each run and is never kept, so it cannot be dropped მთავარი სკრიპტის ძრავა ყოველი გაშვებისთვის ახალია და არასოდეს ინახება, ამიტომ მისი მოცილება შეუძლებელია
@msg there is no script engine named {name} სკრიპტის ძრავა სახელით {name} არ არსებობს
@msg `answers` must be a list of answers `answers` უნდა იყოს პასუხების სია
@msg `answers` has more than {MAX_ANSWERS} answers `answers`-ში {MAX_ANSWERS}-ზე მეტი პასუხია
@msg `answers` is larger than 1 MiB `answers` 1 MiB-ზე დიდია
@msg `answers[{i}]` {e} `answers[{i}]`: {e}
@msg must be an object with `kind` and `value` უნდა იყოს ობიექტი `kind`-ითა და `value`-ით
@msg must have exactly `kind` and `value` უნდა ჰქონდეს ზუსტად `kind` და `value`
@msg is an alert's answer, whose `value` must be "ok" alert-ის პასუხია, ამიტომ მისი `value` უნდა იყოს "ok"
@msg is a confirm's answer, whose `value` must be true or false confirm-ის პასუხია, ამიტომ მისი `value` უნდა იყოს true ან false
@msg is longer than 16 KiB 16 KiB-ზე გრძელია
@msg is a prompt's answer, whose `value` must be a string or null prompt-ის პასუხია, ამიტომ მისი `value` უნდა იყოს სტრიქონი ან null
@msg must have `kind` alert, confirm or prompt `kind` უნდა იყოს alert, confirm ან prompt
@msg `answers` is only for a run with nobody to ask: in the app, the person answers each dialog `answers` მხოლოდ ისეთი გაშვებისთვისაა, სადაც შესაკითხი არავინაა: აპში თითოეულ დიალოგს ადამიანი პასუხობს
@msg Running a script სკრიპტი მუშაობს
@msg Copied the script report კოპირებულია სკრიპტის ანგარიში
Can't render this file because it is too large.