diff --git a/crates/io/src/psd_export/document.rs b/crates/io/src/psd_export/document.rs index b46a21fc3c..d2728f9f24 100644 --- a/crates/io/src/psd_export/document.rs +++ b/crates/io/src/psd_export/document.rs @@ -172,10 +172,11 @@ fn export_supported_document( }) .collect(); let previous = (!text_layers.is_empty()).then(|| preserved.iter().find(|(_, key, _)| key == b"Txt2").map(|(_, _, data)| data.to_vec())).flatten(); - // A fresh document of ordinary (Metrics) text has nothing to put in `Txt2`, and Photoshop never - // writes its empty `<< /0 << >> >>` stub — readers such as Photopea reject it (#3514). Keep the - // block when the file had one (round-trip its pen positions/extras) or a layer is Optical (the - // one mode EngineData can't carry; #1348). + // A fresh document of ordinary (Metrics) text with no Txt2-only OpenType settings has nothing + // to put in `Txt2`, and Photoshop never writes its empty `<< /0 << >> >>` stub — readers such + // as Photopea reject it (#3514). Keep the block when the file had one (round-trip its pen + // positions/extras), a layer is Optical (#1348), or a layer carries stylistic sets / other + // Txt2-only features (#10308). let txt2 = (previous.is_some() || photocraft_text::psd::needs_txt2(&text_layers)) .then(|| photocraft_text::psd::build_txt2_at(&text_layers, previous.as_deref(), ex.dpi)); for (sig, key, data) in preserved { diff --git a/crates/io/tests/it/psd_kerning.rs b/crates/io/tests/it/psd_kerning.rs index d873d4a3e2..bffdb96643 100644 --- a/crates/io/tests/it/psd_kerning.rs +++ b/crates/io/tests/it/psd_kerning.rs @@ -120,6 +120,60 @@ fn fresh_metrics_text_writes_no_txt2_block() { assert!(saves_txt2(Kerning::Optical), "Optical lives only in Txt2"); } +/// #10308: stylistic sets (and other Txt2-only OpenType flags) on a PhotoCraft-native document +/// write a `Txt2` block and round-trip through save and reopen. +#[test] +fn fresh_stylistic_sets_round_trip_through_psd() { + use photocraft_doc::text::FontFeature; + let base = CharStyle { font_family: "Inter".into(), size_pt: 24.0, ..Default::default() }; + let mut t = TextLayer { + text: "Hi".into(), + runs: vec![TextRun { + len: 2, + style: CharStyle { features: vec![FontFeature { tag: "ss01".into(), value: 1 }, FontFeature { tag: "ss05".into(), value: 1 }], ..base }, + }], + ..Default::default() + }; + t.sync_summary(); + let mut doc = Document::new("k", photocraft_geom::Size::new(64, 32), photocraft_color::ColorMode::Rgb, photocraft_color::SampleType::U8); + let mut r = t.clone(); + photocraft_text::TextEngine::new().render_layer(&mut r, doc.resolution_dpi, doc.pixel_format()); + doc.layers.push(Layer::new("t", LayerContent::Text(r))); + let bytes = photocraft_io::export(&doc, "k.psd", &Default::default()).unwrap().bytes; + let file = photocraft_psd::PsdFile::from_bytes(&bytes).unwrap(); + let txt2 = + file.global_blocks.iter().find(|b| &b.key == b"Txt2").and_then(|b| photocraft_text::psd::parse_txt2(&b.data)).expect("Txt2 written for stylistic sets"); + let style = txt2 + .path(&["1", "1"]) + .and_then(E::as_array) + .and_then(|a| a.first()) + .and_then(|o| o.path(&["0", "6", "0"])) + .and_then(E::as_array) + .and_then(|a| a.first()) + .and_then(|r| r.path(&["0", "0", "6"])) + .expect("style run"); + // Bits 0 and 4 → sets 1 and 5. + assert_eq!(style.get("85").and_then(E::as_i64), Some((1 << 0) | (1 << 4))); + assert_eq!(style.path(&["53", "99"]).and_then(E::as_str), Some("SimplePaint"), "paint stream tag"); + assert_eq!(style.path(&["53", "0", "0"]).and_then(E::as_i64), Some(1), "fill colour type RGB"); + assert!(style.path(&["53", "0", "1"]).and_then(E::as_array).is_some_and(|v| v.len() == 4), "fill colour values"); + assert_eq!(style.get("0").and_then(E::as_i64), Some(0), "font index 0"); + assert_eq!( + txt2.path(&["0", "1", "0"]).and_then(E::as_array).and_then(|a| a.first()).and_then(|f| f.path(&["0", "0", "0"])).and_then(E::as_str), + Some("Inter-Regular"), + "fresh Txt2 seeds a font entry" + ); + assert!(txt2.path(&["0", "8", "0"]).and_then(E::as_array).is_some_and(|f| !f.is_empty()), "fresh Txt2 names a frame"); + let back = photocraft_io::import("k.psd", &bytes).unwrap().document; + let LayerContent::Text(b) = &back.layers[0].content else { panic!("not text") }; + let runs = b.char_runs(); + assert_eq!(runs.iter().map(|r| r.len).sum::(), b.text.len(), "the runs cover the text"); + for r in &runs { + let on = |tag: &str| r.style.features.iter().any(|f| f.tag == tag && f.value == 1); + assert!(on("ss01") && on("ss05"), "both sets on every character: {:?}", r.style.features); + } +} + /// Two imported layers can name the same Txt2 object; export must update the second /// preserved TySh pointer so each layer restores its own automatic kerning mode. #[test] diff --git a/crates/text/src/psd/build.rs b/crates/text/src/psd/build.rs index 90568bc06b..755411cd38 100644 --- a/crates/text/src/psd/build.rs +++ b/crates/text/src/psd/build.rs @@ -206,7 +206,7 @@ fn char_spans(layer: &TextLayer) -> Vec<(usize, i64)> { /// (`/11`). Photoshop reads the character style from here rather than from EngineData, and quit /// on a run holding only the auto-kern mode. `None` when `base` has no style dictionary or is /// larger than a template may be (it is copied once per run). -fn txt2_style_runs(layer: &TextLayer, base: &E, fonts: &mut Vec, dpi: f32) -> Option> { +fn txt2_style_runs(layer: &TextLayer, base: &E, fonts: &mut Vec, dpi: f32, seed_empty: bool) -> Option> { if !matches!(base.path(&["0", "0", "6"]), Some(E::Dict(_))) || !fits(base, &mut { TEMPLATE_NODES }) { return None; } @@ -218,7 +218,7 @@ fn txt2_style_runs(layer: &TextLayer, base: &E, fonts: &mut Vec, dpi: f32) -> let mut looked_up = std::collections::HashMap::new(); for (ri, n) in spans { let s = runs.get(ri).map_or(&default, |r| &r.style); - let font = *looked_up.entry(postscript_for(s)).or_insert_with_key(|name| txt2_font(fonts, name)); + let font = *looked_up.entry(postscript_for(s)).or_insert_with_key(|name| txt2_font(fonts, name, seed_empty)); let mut run = base.clone(); let style = run.get_mut("0")?.get_mut("0")?.get_mut("6")?; if let Some(font) = font { @@ -347,8 +347,9 @@ fn txt2_style_agrees(s: &CharStyle, style: &E, fonts: &[E], k: f32) -> bool { return false; } // A mask beyond the 20 sets is ignored on import (`add_txt2_features`), so here too. + // Missing or invalid key 85 counts as 0 (the reader's default), not "any mask agrees". let sets = (0..20).filter(|n| feature(&format!("ss{:02}", n + 1)) == Some(true)).fold(0i64, |m, n| m | 1 << n); - style.get(TXT2_STYLISTIC_SETS).and_then(E::as_i64).filter(|m| (0..1 << 20).contains(m)).is_none_or(|m| m == sets) + style.get(TXT2_STYLISTIC_SETS).and_then(E::as_i64).filter(|m| (0..1 << 20).contains(m)).unwrap_or(0) == sets } /// EngineData's `FontCaps` code of a style: 0 normal, 1 small caps, 2 all caps. @@ -522,14 +523,34 @@ fn td_restyled(entry: &E, layer: &TextLayer, fonts: &mut Vec, dpi: f32) -> Op Some(entry) } +/// A `Txt2` font-list entry (`<< /0 << /99 /CoolTypeFont /0 << /0 name /2 type >> >> >>`). +fn txt2_font_entry(name: &str, kind: i64) -> E { + E::Dict(vec![( + "0".into(), + E::Dict(vec![ + ("99".into(), E::Name("CoolTypeFont".into())), + ("0".into(), E::Dict(vec![("0".into(), E::String(name.to_string())), ("2".into(), E::Int(kind))])), + ]), + )]) +} + /// The index of the PostScript font `name` in a `Txt2` font list (`<< /0 << /99 /CoolTypeFont /// /0 << /0 name /2 type >> >> >>` entries), appending it (shaped like the list's first entry) -/// when missing. `None` for an empty list: there is no entry to shape a new one on. -fn txt2_font(fonts: &mut Vec, name: &str) -> Option { +/// when missing. An empty list gets a seeded CoolTypeFont entry only when `seed_empty` is set — +/// a PhotoCraft-native block (#10308); a file's own block keeps its `/0` as it was (#2374), so +/// `None` there, as before. +fn txt2_font(fonts: &mut Vec, name: &str, seed_empty: bool) -> Option { let named = |f: &E| f.path(&["0", "0", "0"]).and_then(E::as_str) == Some(name); if let Some(i) = fonts.iter().position(named) { return i64::try_from(i).ok(); } + if fonts.is_empty() { + if !seed_empty { + return None; + } + fonts.push(txt2_font_entry(name, 0)); + return Some(0); + } let mut entry = fonts.first()?.clone(); let font = entry.get_mut("0")?.get_mut("0")?; let kind = font.get("2").cloned(); @@ -546,13 +567,69 @@ fn txt2_font(fonts: &mut Vec, name: &str) -> Option { /// `i32::MAX`, and sizing the array by it would make every save allocate gigabytes. pub const MAX_TEXT_INDEX: i32 = 0xFFFF; -/// Whether the document `Txt2` block is needed for `objects`: only a non-Metrics auto-kern mode +/// Whether `style` carries an OpenType setting that lives only in `Txt2` (EngineData has no field +/// for stylistic sets or the [`TXT2_FEATURES`] flags). Defaults that match a plain style do not +/// count: Contextual Alternates on (or absent), and the other flags off. +fn txt2_only_opentype(style: &CharStyle) -> bool { + let on = |tag: &str| style.features.iter().any(|f| f.tag == tag && f.value > 0); + let off = |tag: &str| style.features.iter().any(|f| f.tag == tag && f.value == 0); + if (1..=20).any(|n| on(&format!("ss{n:02}"))) { + return true; + } + for (_, tag) in TXT2_FEATURES { + if tag == "calt" { + if off("calt") { + return true; + } + } else if on(tag) { + return true; + } + } + false +} + +/// Whether the document `Txt2` block is needed for `objects`: a non-Metrics auto-kern mode /// (`Optical`) is exclusive to `Txt2` — EngineData's `AutoKerning` cannot distinguish Metrics from -/// Optical — so a fresh document of ordinary Metrics text has nothing to put in the block. -/// Writing Photoshop's empty `<< /0 << >> >>` stub anyway makes some readers (Photopea) fail -/// (#3514); the export omits the block for such a document. +/// Optical — and so are Stylistic Sets and the other [`TXT2_FEATURES`] flags (#10308). A fresh +/// document of ordinary Metrics text with no such OpenType settings has nothing to put in the +/// block. Writing Photoshop's empty `<< /0 << >> >>` stub anyway makes some readers (Photopea) +/// fail (#3514); the export omits the block for such a document. pub fn needs_txt2(objects: &[(i32, &TextLayer)]) -> bool { - objects.iter().any(|(_, l)| l.char_runs().iter().any(|r| r.style.kerning == Kerning::Optical)) + objects.iter().any(|(_, l)| l.char_runs().iter().any(|r| r.style.kerning == Kerning::Optical || txt2_only_opentype(&r.style))) +} + +/// A `/53` SimplePaint dictionary (`<< /99 /SimplePaint /0 << >> >>`) for a fresh style run. +fn simple_paint_dict() -> E { + E::Dict(vec![("99".into(), E::Name("SimplePaint".into())), ("0".into(), E::dict())]) +} + +/// A minimal `Txt2` style run Photoshop will read: the shape [`txt2_style_runs`] fills from a +/// layer when the file has no template object to copy (a PhotoCraft-native document). Includes an +/// empty `/53` SimplePaint dict so the fill colour can be written. +fn minimal_txt2_style_run() -> E { + let style = E::Dict(vec![("0".into(), E::Int(0)), ("11".into(), E::Int(1)), ("53".into(), simple_paint_dict())]); + let data = E::Dict(vec![("0".into(), E::String(String::new())), ("6".into(), style)]); + E::Dict(vec![("0".into(), E::Dict(vec![("0".into(), data)])), ("1".into(), E::Int(1))]) +} + +/// A point-text object with a view naming frame `frame` and empty style runs, for a layer the +/// file's block has no object for and no template to copy (#10308, #7698). Style runs are filled +/// by [`txt2_style_runs`] next. +fn fresh_point_text_object(frame: usize, text: &str) -> E { + let frame = i64::try_from(frame).unwrap_or(0); + let view = E::Dict(vec![("0".into(), E::Array(vec![E::Dict(vec![("0".into(), E::Int(frame))])]))]); + // One paragraph run per `\r`-terminated paragraph (lengths in UTF-16 code units), as + // `edited_object` refits them. + let paragraphs = text + .split_inclusive('\r') + .map(|p| E::Dict(vec![("0".into(), E::dict()), ("1".into(), E::Int(i64::try_from(p.encode_utf16().count()).unwrap_or(i64::MAX)))])) + .collect(); + let model = E::Dict(vec![ + ("0".into(), E::String(text.to_string())), + ("5".into(), E::Dict(vec![("0".into(), E::Array(paragraphs))])), + ("6".into(), E::Dict(vec![("0".into(), E::Array(vec![]))])), + ]); + E::Dict(vec![("0".into(), model), ("1".into(), view)]) } /// The document's `Txt2` block for `objects`: `(TextIndex, layer)` pairs, one text object each @@ -598,6 +675,11 @@ pub fn build_txt2_at(objects: &[(i32, &TextLayer)], previous: Option<&[u8]>, dpi let td_fonts_before = td_fonts.len(); let mut fonts: Vec = prev.as_ref().and_then(|p| p.path(&["0", "1", "0"]).and_then(E::as_array)).map(<[E]>::to_vec).unwrap_or_default(); let fonts_before = fonts.len(); + // A PhotoCraft-native block: the document had no `Txt2` of its own (#10308). Only such a + // block gets the fresh point-text objects, minimal style runs, seeded font list and frame + // list below; a file's own block (Photoshop's, any era) is written as before (#2374, #7698). + let native = prev.is_none(); + let seed_empty = native; // Looked up once per save, not per layer: a crafted block with many objects must not cost // a pass over all of them for every type layer. let all_stubs = prev_objects.iter().all(is_stub); @@ -671,11 +753,15 @@ pub fn build_txt2_at(objects: &[(i32, &TextLayer)], previous: Option<&[u8]>, dpi // can't be refitted keeps the frame that object was drawn in. let fresh = (kept.is_none() && edited.is_none()) .then(|| { - let template = template?; + // Without a template, only a PhotoCraft-native block gets a fresh object; a file's + // block keeps the stub it always got. + if template.is_none() && !native { + return None; + } let own = slot.and_then(|o| object_frame(o, true)).filter(|f| frame_count.is_some_and(|n| *f < n)); let frame = match own { Some(f) => f, - None if frame_count.is_some() && taken.contains(&at) => { + None if (frame_count.is_some() || template.is_none()) && taken.contains(&at) => { while taken.contains(&next_free) { next_free += 1; } @@ -683,7 +769,12 @@ pub fn build_txt2_at(objects: &[(i32, &TextLayer)], previous: Option<&[u8]>, dpi } None => at, }; - let object = new_object(template, frame, &text)?; + // Prefer a file object as template (#7698); otherwise a point-text object with a + // view naming its own frame so a PhotoCraft-native Txt2 still opens (#10308). + let object = match template { + Some(template) => new_object(template, frame, &text)?, + None => fresh_point_text_object(frame, &text), + }; taken.insert(frame); frames_needed = frames_needed.max(frame.saturating_add(1)); Some(object) @@ -695,11 +786,15 @@ pub fn build_txt2_at(objects: &[(i32, &TextLayer)], previous: Option<&[u8]>, dpi let mut model = object.get("0").cloned().filter(|m| matches!(m, E::Dict(_))).unwrap_or_else(E::dict); // A new or edited object takes the layer's own style: Photoshop reads the character style // from these runs, so the template's (or the old text's) would show, and come back on - // reopen. They are built on one of the object's own runs, every key Photoshop wrote kept. - let styled = (!unchanged && !is_stub(&object)) - .then(|| model.path(&["6", "0"]).and_then(E::as_array).and_then(<[E]>::first).cloned()) - .flatten() - .and_then(|base| txt2_style_runs(layer, &base, &mut fonts, dpi)); + // reopen. They are built on one of the object's own runs, every key Photoshop wrote kept; + // without a template run, a minimal base is filled the same way (#10308). + let styled = (!unchanged) + .then(|| { + let file_base = (!is_stub(&object)).then(|| model.path(&["6", "0"]).and_then(E::as_array).and_then(<[E]>::first).cloned()).flatten(); + let base = file_base.or_else(|| native.then(minimal_txt2_style_run))?; + txt2_style_runs(layer, &base, &mut fonts, dpi, seed_empty) + }) + .flatten(); let file_runs = reuse.then(|| model.path(&["6", "0"]).and_then(E::as_array)).flatten().and_then(|runs| with_modes(runs, &modes)); let runs = styled.or(file_runs).unwrap_or_else(|| { modes @@ -729,8 +824,15 @@ pub fn build_txt2_at(objects: &[(i32, &TextLayer)], previous: Option<&[u8]>, dpi } } // The outer dictionary keeps whatever the block held (`/98` version, block extras, …), and - // `/1` whatever it holds beside the text objects. - let mut outer = prev.clone().unwrap_or_else(|| E::Dict(vec![("98".into(), E::Dict(vec![("0".into(), E::Int(14))])), ("0".into(), E::dict())])); + // `/1` whatever it holds beside the text objects. A PhotoCraft-native block gets a frame list + // (`/0 /8 /0`) so each object's view can name a frame (#10308, #7698); a file's block is never + // given a `/0` or a frame list it didn't have (#2374). + let mut outer = prev.clone().unwrap_or_else(|| { + E::Dict(vec![ + ("98".into(), E::Dict(vec![("0".into(), E::Int(14))])), + ("0".into(), E::Dict(vec![("8".into(), E::Dict(vec![("0".into(), E::Array(vec![]))]))])), + ]) + }); pad_frames(&mut outer, slots.len().max(frames_needed)); // A path layer's frame holds its path; a layer taken off its path loses its path frame. An // unchanged path leaves the file's frame as it was, and so does a frame the file already had @@ -749,10 +851,18 @@ pub fn build_txt2_at(objects: &[(i32, &TextLayer)], previous: Option<&[u8]>, dpi } } } + // Write the font list whenever it grew. Create `/0/1` only in a PhotoCraft-native block; + // otherwise leave the file's `/0` alone (#2374). if fonts.len() != fonts_before - && let Some(list @ E::Dict(_)) = outer.get_mut("0").and_then(|v| v.get_mut("1")) + && let Some(doc @ E::Dict(_)) = outer.get_mut("0") { - list.set("0", E::Array(fonts)); + match doc.get_mut("1") { + Some(list @ E::Dict(_)) => list.set("0", E::Array(fonts)), + _ if seed_empty => { + doc.set("1", E::Dict(vec![("0".into(), E::Array(fonts))])); + } + _ => {} + } } match outer.get_mut("1") { Some(objs @ E::Dict(_)) => objs.set("1", E::Array(slots)), diff --git a/crates/text/src/tests.rs b/crates/text/src/tests.rs index a3ab6cd978..f2792a3850 100644 --- a/crates/text/src/tests.rs +++ b/crates/text/src/tests.rs @@ -1062,12 +1062,12 @@ fn build_txt2_round_trips_kerning_modes() { assert_eq!(modes, vec![(1, Kerning::Off), (1, Kerning::Metrics)]); } -/// #3514: the document `Txt2` is only needed for a non-Metrics (`Optical`) auto-kern mode. A fresh -/// document of ordinary Metrics (or EngineData-carried Off) text must not write Photoshop's empty -/// stub, which some readers (Photopea) reject. +/// #3514 / #10308: the document `Txt2` is needed for Optical kerning and for OpenType settings +/// EngineData can't carry (stylistic sets, swashes, …). A fresh document of ordinary Metrics text +/// must not write Photoshop's empty stub, which some readers (Photopea) reject. #[test] -fn needs_txt2_only_for_optical() { - use photocraft_doc::text::Kerning; +fn needs_txt2_for_optical_and_txt2_only_opentype() { + use photocraft_doc::text::{FontFeature, Kerning}; let style = |kerning: Kerning| CharStyle { kerning, ..Default::default() }; let metrics = runs_of("AV", &[(2, style(Kerning::Metrics))]); assert!(!crate::psd::needs_txt2(&[(0, &metrics)])); @@ -1076,6 +1076,57 @@ fn needs_txt2_only_for_optical() { let optical = runs_of("AV", &[(1, style(Kerning::Optical)), (1, CharStyle::default())]); assert!(crate::psd::needs_txt2(&[(0, &optical)])); assert!(!crate::psd::needs_txt2(&[])); + let with_ss = |tag: &str, value: u16| { + let mut s = style(Kerning::Metrics); + s.features = vec![FontFeature { tag: tag.into(), value }]; + runs_of("AV", &[(2, s)]) + }; + assert!(crate::psd::needs_txt2(&[(0, &with_ss("ss01", 1))]), "stylistic set 1 lives only in Txt2"); + assert!(crate::psd::needs_txt2(&[(0, &with_ss("ss05", 1))]), "stylistic set 5 lives only in Txt2"); + assert!(!crate::psd::needs_txt2(&[(0, &with_ss("ss01", 0))]), "an off set is the default"); + assert!(crate::psd::needs_txt2(&[(0, &with_ss("swsh", 1))]), "swash lives only in Txt2"); + assert!(crate::psd::needs_txt2(&[(0, &with_ss("calt", 0))]), "calt off is Txt2-only"); + assert!(!crate::psd::needs_txt2(&[(0, &with_ss("calt", 1))]), "calt on is the default"); +} + +/// #10308: the fresh objects, minimal style runs, seeded font list and frame list are only for a +/// PhotoCraft-native block. A file's own block — here the older Photoshop's, with an empty +/// numbered `/0` or none at all — gets no `/0` key, frame list or font list it didn't have, and +/// a layer without a template object gets the stub it always got. +#[test] +fn photoshop_blocks_get_no_native_txt2_scaffolding() { + use crate::engine_data::Value as E; + use photocraft_doc::text::FontFeature; + let style = CharStyle { font_family: "Inter".into(), features: vec![FontFeature { tag: "ss01".into(), value: 1 }], ..Default::default() }; + let t = styled("Hi", style); + let with_doc = photoshop_era_txt2(&["Line 1"]); + let without_doc = crate::engine_data::write_bare(&[ + ("98".into(), E::Dict(vec![("0".into(), E::Int(14))])), + ("DocumentObjects".into(), photoshop_era_objects(&["Line 1"])), + ]); + for (label, prev, doc) in [("empty /0", with_doc, Some(E::dict())), ("no /0", without_doc, None)] { + let out = crate::psd::parse_txt2(&crate::psd::build_txt2(&[(0, &t)], Some(&prev))).unwrap(); + assert_eq!(out.get("0").cloned(), doc, "{label}: the file's /0 is left as it was"); + let object = out.path(&["1", "1"]).and_then(E::as_array).and_then(|a| a.first()).expect("the numbered object"); + assert!(object.get("1").is_none(), "{label}: no fresh view naming a frame the file has no list for"); + assert!(object.path(&["0", "5"]).is_none(), "{label}: no fresh paragraph runs"); + } +} + +/// #10308: a fresh native object has one paragraph run per paragraph, each its UTF-16 length. +#[test] +fn fresh_native_txt2_object_has_a_paragraph_run_per_paragraph() { + use crate::engine_data::Value as E; + use photocraft_doc::text::FontFeature; + let style = CharStyle { features: vec![FontFeature { tag: "ss02".into(), value: 1 }], ..Default::default() }; + let t = styled("Hi\nBy\u{e9}e", style); + let out = crate::psd::parse_txt2(&crate::psd::build_txt2(&[(0, &t)], None)).unwrap(); + let object = out.path(&["1", "1"]).and_then(E::as_array).and_then(|a| a.first()).expect("the object"); + assert_eq!(object.path(&["0", "0"]).and_then(E::as_str), Some("Hi\rBy\u{e9}e\r")); + let lens: Vec = + object.path(&["0", "5", "0"]).and_then(E::as_array).expect("paragraph runs").iter().filter_map(|r| r.get("1").and_then(E::as_i64)).collect(); + assert_eq!(lens, vec![3, 5]); + assert_eq!(out.path(&["0", "8", "0"]).and_then(E::as_array).map(<[E]>::len), Some(1), "a native block names one frame"); } /// A kept `Txt2` object — same text, so its extras are still true — keeps everything the file diff --git a/docs/gaps.md b/docs/gaps.md index 207fbf2888..ef86e534cd 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Where PhotoCraft falls short of Photoshop -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-02 · **Change:** minor (G10: TIFF Options dialog on Save As and Save a Copy, compression, Save Image Pyramid, Save Transparency, #8827; G11: Batch Esc Continue/Stop and read-only input previews; full live tabs remain open, #4579; G11: action recording folds Move-tool nudges, records relative keyboard document switches and scales point text placement; paragraph boxes remain open, #4514; G11: Batch measured output naming and UTF-16 log corrections; remaining progress and cancel prompt parity tracked, #4579; G11: Render ATN events mapped; Stylize/Pixelate ATN events mapped, current counts 128 supported/89 unmapped; G9: 11 of 183 preferences do nothing: startup reads Graphics Adapter through the typed Performance section, so the scorecard audit sees it; selected colour sets edit drawing, tone and supported filters; geometry remains open; G11: `.atn` document offsets preserve opening order after tab reordering, #7103; embedded AI/PDF/EPS save-back retains native format with a source-bound SVG display preview; Smooth and Feather command masks cropped to selection bounds plus blur reach; G1: Halftone Pattern Filter Gallery settings survive PSD/PSB saves (#8940); cropped selection morphology and command mask conversion performance evidence added; G6: Art History Brush landed as partial, TOOL-213-20, #1610, so no toolbar tool is missing; G4: five hard-round built-in presets use 5% spacing to remove stacked-tip outlines and reduce pressure-opacity bands, #8842; G9: Crop tool canvas menu, #6561; G2: Content-Aware Scale seam carving 1.65–3.6× faster with unchanged output, P28 row 3.3 → 1.6 s on a 4-core VM, #5236; G9: UI scale presets done, 105–120% steps, #3222; G14: lossy DNG, raw sidecars, Camera Raw Defaults live, Calibration and Auto, CR3 assessed as not clean-room feasible; G8: PSD type on a path opens on its path and saves back into the file's `Txt2`, #7962; G11: a recorded Save As imports with its format and file (`file.saveAs`, `file.saveACopy` for As a Copy) instead of as a plain Save that wrote over the played file, #7102; folder destinations stop playback until #5430; adjustment clipping stays visible in compact Properties, #5231; G9: Color panel modes, ramp and copy commands, the same in every theme, UI-217-17, #6000; G17: Help › Check for Updates and an opt-out check once per launch, DIST-220-1 partial, #5485; G10: `.asl` style libraries landed, #1051; G8: area type (TYPE-218-10); G1: smart objects keep Photoshop's Cylinder warp, #4112; G8: paragraph direction buttons in the Paragraph panel and options bar, TYPE-218-2 partial; G1: 32-bit Hue/Saturation and Colorize as Photoshop does them, Photoshop-oracle floor 190/258, #5781; G11: compound layer properties export as separate Photoshop Set events, rename last, #8304; G11: Batch and droplets take the result at the action's Save step, so actions ending in Save As and Close work; G11: `.atn` steps that switch to another open document import, play and save back, #7103; G14: the Nikon D4 white level follows the sample depth, so 12-bit D4 NEFs no longer open 2.6 stops dark, #5978; G14: a Nikon NEF's Adobe RGB preview is read as Adobe RGB (maker-note ColorSpace 0x001E), #5987; Apply Layer Comp action mapping, #7101; G10: JPEG Options dialog landed, FILE-215-19 partial (no Matte, progressive Scans or size preview); G10: Cineon write; G10: DPX read and write, #1049, Cineon and Amiga IFF read; Classical Object Finder improvement; learned segmentation remains open; G4: named, stateful section locks and visible keyboard focus in Brush Settings; G4: independent Brush Pose tilt-axis overrides, #3825 partial; G4: Transfer Mixer-only controls, #3825 partial; G9: Preferences › File Handling › Save in Background takes effect, #6207, 24 of 169 preferences do nothing; G7: Content-Aware Move previews every selection the command takes, coarse then exact, TOOL-213-4 done, #6680; G4: Pattern Stamp and Background Eraser draw live, TOOL-213-7; G9: Animated Zoom pref read: holding the Zoom tool zooms continuously, #6210, prefs that do nothing 25 of 166; G2: a cancelled 24 MP Gaussian Blur job stops in at most 44 ms, P25 under its 200 ms budget in local runs, baseline not re-run, #6205; G1: generated large-file fixtures, a 4.38 GB PSB opens on Windows through io, FILE-216-2 done, #5107; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; G7: Field Blur's on-canvas pins, #3373; G4: Hue Jitter amount track, #3825 partial; G4: minimum field interaction, #3825 partial; G1: CMYK Invert, Posterize and Threshold on the inks, 16-bit Lab Invert; Photoshop-oracle floor 145/258; G11: `.atn` import maps 112 events: Select and Mask, Filter Gallery Spatter, Ripple, Crystallize, Pattern Fill layers, mask targeting, Step Backward, nudges in points, Bitmap mode; G5: Free Transform H/V skew fields; G9: toolbar tool shortcut editing; refreshed against main: G2, G5, G7, G9, G10, G13, G14, G17 items that landed; G10: DPX read and write, #1049; G4: checkbox-only Brush Settings rows; G11: Load/Save Actions `.atn` landed, AUTO-219-2 partial; G5: hold-a-key spring-loaded tools landed, #2672; G1: #2465 fixed; stale missing-tool rows corrected: Color Replacement, Red Eye and Add/Delete Anchor Point are live tools, so only Art History Brush is missing; no estimate changed; G10: Amiga IFF write; G10: PSD spot channels in Photoshop's polarity, earlier PhotoCraft PSDs keep their ink, #7415 split; G10: TIFF alpha and spot channels written and read as extra samples, FILE-215-7 done, FILE-215-17's TIFF part, #7415) · **Target:** Adobe Photoshop 2026 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-04 · **Change:** minor (G8: PhotoCraft-native PSDs keep stylistic sets and other Txt2-only OpenType flags through save/reopen, #10308; G10: TIFF Options dialog on Save As and Save a Copy, compression, Save Image Pyramid, Save Transparency, #8827; G11: Batch Esc Continue/Stop and read-only input previews; full live tabs remain open, #4579; G11: action recording folds Move-tool nudges, records relative keyboard document switches and scales point text placement; paragraph boxes remain open, #4514; G11: Batch measured output naming and UTF-16 log corrections; remaining progress and cancel prompt parity tracked, #4579; G11: Render ATN events mapped; Stylize/Pixelate ATN events mapped, current counts 128 supported/89 unmapped; G9: 11 of 183 preferences do nothing: startup reads Graphics Adapter through the typed Performance section, so the scorecard audit sees it; selected colour sets edit drawing, tone and supported filters; geometry remains open; G11: `.atn` document offsets preserve opening order after tab reordering, #7103; embedded AI/PDF/EPS save-back retains native format with a source-bound SVG display preview; Smooth and Feather command masks cropped to selection bounds plus blur reach; G1: Halftone Pattern Filter Gallery settings survive PSD/PSB saves (#8940); cropped selection morphology and command mask conversion performance evidence added; G6: Art History Brush landed as partial, TOOL-213-20, #1610, so no toolbar tool is missing; G4: five hard-round built-in presets use 5% spacing to remove stacked-tip outlines and reduce pressure-opacity bands, #8842; G9: Crop tool canvas menu, #6561; G2: Content-Aware Scale seam carving 1.65–3.6× faster with unchanged output, P28 row 3.3 → 1.6 s on a 4-core VM, #5236; G9: UI scale presets done, 105–120% steps, #3222; G14: lossy DNG, raw sidecars, Camera Raw Defaults live, Calibration and Auto, CR3 assessed as not clean-room feasible; G8: PSD type on a path opens on its path and saves back into the file's `Txt2`, #7962; G11: a recorded Save As imports with its format and file (`file.saveAs`, `file.saveACopy` for As a Copy) instead of as a plain Save that wrote over the played file, #7102; folder destinations stop playback until #5430; adjustment clipping stays visible in compact Properties, #5231; G9: Color panel modes, ramp and copy commands, the same in every theme, UI-217-17, #6000; G17: Help › Check for Updates and an opt-out check once per launch, DIST-220-1 partial, #5485; G10: `.asl` style libraries landed, #1051; G8: area type (TYPE-218-10); G1: smart objects keep Photoshop's Cylinder warp, #4112; G8: paragraph direction buttons in the Paragraph panel and options bar, TYPE-218-2 partial; G1: 32-bit Hue/Saturation and Colorize as Photoshop does them, Photoshop-oracle floor 190/258, #5781; G11: compound layer properties export as separate Photoshop Set events, rename last, #8304; G11: Batch and droplets take the result at the action's Save step, so actions ending in Save As and Close work; G11: `.atn` steps that switch to another open document import, play and save back, #7103; G14: the Nikon D4 white level follows the sample depth, so 12-bit D4 NEFs no longer open 2.6 stops dark, #5978; G14: a Nikon NEF's Adobe RGB preview is read as Adobe RGB (maker-note ColorSpace 0x001E), #5987; Apply Layer Comp action mapping, #7101; G10: JPEG Options dialog landed, FILE-215-19 partial (no Matte, progressive Scans or size preview); G10: Cineon write; G10: DPX read and write, #1049, Cineon and Amiga IFF read; Classical Object Finder improvement; learned segmentation remains open; G4: named, stateful section locks and visible keyboard focus in Brush Settings; G4: independent Brush Pose tilt-axis overrides, #3825 partial; G4: Transfer Mixer-only controls, #3825 partial; G9: Preferences › File Handling › Save in Background takes effect, #6207, 24 of 169 preferences do nothing; G7: Content-Aware Move previews every selection the command takes, coarse then exact, TOOL-213-4 done, #6680; G4: Pattern Stamp and Background Eraser draw live, TOOL-213-7; G9: Animated Zoom pref read: holding the Zoom tool zooms continuously, #6210, prefs that do nothing 25 of 166; G2: a cancelled 24 MP Gaussian Blur job stops in at most 44 ms, P25 under its 200 ms budget in local runs, baseline not re-run, #6205; G1: generated large-file fixtures, a 4.38 GB PSB opens on Windows through io, FILE-216-2 done, #5107; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; G7: Field Blur's on-canvas pins, #3373; G4: Hue Jitter amount track, #3825 partial; G4: minimum field interaction, #3825 partial; G1: CMYK Invert, Posterize and Threshold on the inks, 16-bit Lab Invert; Photoshop-oracle floor 145/258; G11: `.atn` import maps 112 events: Select and Mask, Filter Gallery Spatter, Ripple, Crystallize, Pattern Fill layers, mask targeting, Step Backward, nudges in points, Bitmap mode; G5: Free Transform H/V skew fields; G9: toolbar tool shortcut editing; refreshed against main: G2, G5, G7, G9, G10, G13, G14, G17 items that landed; G10: DPX read and write, #1049; G4: checkbox-only Brush Settings rows; G11: Load/Save Actions `.atn` landed, AUTO-219-2 partial; G5: hold-a-key spring-loaded tools landed, #2672; G1: #2465 fixed; stale missing-tool rows corrected: Color Replacement, Red Eye and Add/Delete Anchor Point are live tools, so only Art History Brush is missing; no estimate changed; G10: Amiga IFF write; G10: PSD spot channels in Photoshop's polarity, earlier PhotoCraft PSDs keep their ink, #7415 split; G10: TIFF alpha and spot channels written and read as extra samples, FILE-215-7 done, FILE-215-17's TIFF part, #7415) · **Target:** Adobe Photoshop 2026 Every known shortfall against Photoshop 2026 (27.11.0), one entry each, ranked by user impact on the way to beta. This is the work list agents pick from: take the highest-ranked entry that @@ -101,7 +101,8 @@ what an agent can't finish alone. (TYPE-218-3), OpenType Stylistic Sets submenu and greying out features the font lacks (TYPE-218-5; Character panel buttons 2026-10-11, #3752; Numerals submenu 2026-11-03 — `.pcraft` keeps all figure tags; PSD EngineData only `OldStyle`/`onum` until a Photoshop-authored - oracle lands), text free transform + oracle lands; PhotoCraft-native PSDs keep stylistic sets and other Txt2-only flags through + save/reopen since 2026-11-04, #10308; the Type › OpenType › Stylistic Sets menu is #10285 / PR #10304), text free transform (#2630), area type in PSD (TYPE-218-10). Done since the re-measure: manual and optical kerning with PSD round trip (TYPE-218-6, #206), variable-font axes (TYPE-218-4, #2985), Warp on live type without a rasterize prompt, as in Photoshop (TYPE-218-9, #3004), and the live Warp Text preview that opens @@ -545,6 +546,7 @@ what an agent can't finish alone. | 2026-10-11 | minor | G13: Czech dynamic UI text localized; engine messages and native review remain open | | 2026-10-11 | minor | G8: triple/quadruple/five-click type selection done (TYPE-218-8, #3493); Type evidence recounted | | 2026-10-11 | minor | G4: Pattern Stamp and Background Eraser draw live, Spot Healing shows a dark overlay while dragging (#3754); only the Mixer Brush is left of TOOL-213-7 | +| 2026-11-04 | minor | G8: PhotoCraft-native PSDs keep stylistic sets and other Txt2-only OpenType flags through save/reopen (#10308); Stylistic Sets menu still #10285 | | 2026-11-03 | minor | G8: Type › OpenType › Numerals submenu landed (TYPE-218-5); `.pcraft` keeps figure tags, PSD only `OldStyle`/`onum` for now; Stylistic Sets and font-feature greying still missing | | 2026-10-11 | minor | G8: Character panel OpenType buttons landed (TYPE-218-5, #3752); Numerals and Stylistic Sets submenus still missing | | 2026-10-11 | minor | G10: one-page flattened PDF write shipped (io::pdf, #3401); FILE-215-10 now partial |