PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Merge PR #6230: feat(type): area type, text that wraps inside a closed path or shape
David Manna8f91f54ad4b
diff --cc crates/engine/src/canvas_geom.rsindex 323313513,8de32f432..77ac5a2d0--- a/crates/engine/src/canvas_geom.rs+++ b/crates/engine/src/canvas_geom.rs@@@ -77,40 -77,6 +77,41 @@@ fn retag_text(dpi: f32, t: &mut TextLayt.psd_raw = Some(Arc::new(photocraft_text::psd::build_tysh(t, dpi, layout.bounds())));}+/// Sets the document resolution keeping every type layer's size in pixels, as Photoshop does (its+/// point size changes instead). Text space is in pixels at `pt x dpi / 72`, so it grows by+/// new / old: box and path scale with it, and the layer transform undoes that.+pub(crate) fn set_resolution(doc: &mut Document, dpi: f32) {+ let old = std::mem::replace(&mut doc.resolution_dpi, dpi);+ if !(old.is_finite() && old > 0.0 && dpi.is_finite() && dpi > 0.0) || old == dpi {+ return;+ }+ let k = f64::from(dpi) / f64::from(old);+ let grow = Affine::scale(k);+ crate::image_cmds::for_each_layer(&mut doc.layers, &mut |l| {+ let LayerContent::Text(t) = &mut l.content else { return };+ t.transform = t.transform.mul(&Affine::scale(1.0 / k));+ match &mut t.shape {+ photocraft_doc::text::TextShape::Box { x, y, width, height } => {+ for v in [x, y, width, height] {+ *v = grown(*v, k);+ }+ }+ photocraft_doc::text::TextShape::Path { path, start, .. } => {+ path.knots.iter_mut().for_each(|kn| *kn = kn.transform(&grow));+ *start = grown(*start, k);+ }++ photocraft_doc::text::TextShape::Area { path } => *path = path.transform(&grow),+ photocraft_doc::text::TextShape::Point => {}+ }+ retag_text(dpi, t);+ });+}++/// `v x k` kept finite (a huge box from a file must not become infinite).+fn grown(v: f32, k: f64) -> f32 {+ (f64::from(v) * k).clamp(-f64::from(f32::MAX), f64::from(f32::MAX)) as f32+}+/// Applies `a` to one layer's (and its children's) non-pixel geometry. With `content` false only/// the parts Free Transform (`transform_layer`) doesn't move are touched: unlinked vector masks,/// gradient fill angles, effect reference points and artboards.diff --cc crates/engine/src/type_area_cmds/tests.rsindex 000000000,daa60edc2..ea296015emode 000000,100644..100644--- a/crates/engine/src/type_area_cmds/tests.rs+++ b/crates/engine/src/type_area_cmds/tests.rs@@@ -1,0 -1,203 +1,232 @@@+ use super::*;+ use photocraft_doc::text::TextShape;+ use photocraft_doc::vector::{Path, PathOp, Subpath};+ use photocraft_doc::{LayerContent, LayerId, TextLayer};+ use serde_json::json;++ fn session(depth: u32) -> Session {+ let mut s = Session::new();+ s.execute("file.new", json!({"width": 400, "height": 300, "depth": depth, "background": "white"})).unwrap();+ s+ }++ fn text_layer(s: &mut Session, text: &str) -> LayerId {+ let r = s.execute("type.create", json!({"x": 100, "y": 100, "text": text, "size": 14, "color": "#000000"})).unwrap();+ LayerId(r["layer"].as_u64().unwrap())+ }++ fn text(s: &Session, id: LayerId) -> &TextLayer {+ match &s.active().unwrap().doc.layer(id).unwrap().content {+ LayerContent::Text(t) => t,+ c => panic!("not text: {}", c.kind_name()),+ }+ }++ fn set_work_path(s: &mut Session, p: Path) {+ s.edit("path", |doc, _| {+ doc.work_path = Some(p);+ Ok(())+ })+ .unwrap();+ }++ const WORDS: &str = "Well, that went better than expected. Now where did the cat hide the keys?";++ #[test]+ fn fill_path_wraps_text_inside_the_work_path_in_one_step() {+ for depth in [8, 16, 32] {+ let mut s = session(depth);+ let id = text_layer(&mut s, WORDS);+ set_work_path(&mut s, Path::new(vec![Subpath::polygon(&[(50.0, 50.0), (250.0, 50.0), (250.0, 200.0), (50.0, 200.0)])]));+ let steps = s.active().unwrap().history.entries().len();+ let r = s.execute("type.fillPath", json!({})).unwrap();+ assert_eq!(r["layer"], json!(id.0));+ assert_eq!(s.active().unwrap().history.entries().len(), steps + 1, "one history step");+ assert!(matches!(text(&s, id).shape, TextShape::Area { .. }));+ // The ink stays inside the path, in document space.+ let ink = s.active().unwrap().doc.layer(id).unwrap().surface().unwrap().content_bounds();+ assert!(ink.x0 >= 49 && ink.x1 <= 251 && ink.y0 >= 49 && ink.y1 <= 201, "depth {depth}: {ink:?}");+ assert!(ink.height() > 30, "several lines");+ assert!(s.undo());+ assert_eq!(text(&s, id).shape, TextShape::Point);+ assert!(s.redo());+ assert!(matches!(text(&s, id).shape, TextShape::Area { .. }));+ }+ }++ #[test]+ fn fill_path_uses_a_shape_layer_with_its_hole() {+ let mut s = session(8);+ let shape = s.execute("shape.create", json!({"kind": "rect", "rect": [20, 20, 300, 200], "fill": "#cccccc"})).unwrap()["layer"].as_u64().unwrap();+ s.execute("shape.create", json!({"kind": "rect", "rect": [140, 80, 60, 80], "addTo": shape, "op": "subtract"})).unwrap();+ let id = text_layer(&mut s, &WORDS.repeat(3));+ s.execute("type.fillPath", json!({"layer": id.0, "shape": shape})).unwrap();+ let TextShape::Area { path } = &text(&s, id).shape else { panic!("area") };+ assert_eq!(path.subpaths.len(), 2);+ assert_eq!(path.subpaths[1].op, PathOp::Subtract);+ }++ #[test]+ fn fill_path_maps_the_path_into_text_space() {+ let mut s = session(8);+ let id = text_layer(&mut s, WORDS); // transform: translate(100, 100)+ set_work_path(&mut s, Path::new(vec![Subpath::polygon(&[(100.0, 100.0), (300.0, 100.0), (300.0, 250.0), (100.0, 250.0)])]));+ s.execute("type.fillPath", json!({})).unwrap();+ let TextShape::Area { path } = &text(&s, id).shape else { panic!("area") };+ let a = path.subpaths[0].knots[0].anchor;+ assert!((a.x, a.y) == (0.0, 0.0), "{a:?}");+ }++ #[test]+ fn fill_path_rejects_bad_paths_without_history() {+ let mut s = session(8);+ assert!(!s.is_enabled("type.fillPath"), "no type layer");+ let id = text_layer(&mut s, WORDS);+ assert!(s.is_enabled("type.fillPath"));+ let history = |s: &Session| s.active().unwrap().history.entries().len();+ // No work path.+ assert!(s.execute("type.fillPath", json!({})).is_err());+ for bad in [+ Path::new(vec![Subpath::polyline(&[(0.0, 0.0), (90.0, 90.0), (0.0, 90.0)])]), // open only+ Path::new(vec![Subpath::polygon(&[(0.0, 0.0), (90.0, 0.0), (180.0, 0.0)])]), // no area+ Path::new(vec![Subpath::polygon(&[(0.0, 0.0), (f64::NAN, 0.0), (9.0, 9.0)])]),+ {+ let mut p = Path::new(vec![Subpath::polygon(&[(0.0, 0.0), (90.0, 0.0), (90.0, 90.0)])]);+ p.inverted = true;+ p+ },+ Path::new(vec![Subpath::polygon(&(0..100_001).map(|i| ((i as f64).cos() * 90.0, (i as f64).sin() * 90.0)).collect::<Vec<_>>())]),+ ] {+ set_work_path(&mut s, bad);+ let h = history(&s);+ assert!(s.execute("type.fillPath", json!({})).is_err());+ assert_eq!(history(&s), h, "no history step on error");+ assert_eq!(text(&s, id).shape, TextShape::Point);+ }+ // Bad params, a shape param that is not a shape layer, and a locked layer: each refused+ // without a history step or a change to the layer.+ let refused = |s: &mut Session, p: serde_json::Value| {+ let h = history(s);+ assert!(s.execute("type.fillPath", p.clone()).is_err(), "{p}");+ assert_eq!(history(s), h, "no history step on error: {p}");+ assert_eq!(text(s, id).shape, TextShape::Point, "{p}");+ };+ for p in [json!({"shape": "x"}), json!({"shape": u64::MAX}), json!({"layer": u64::MAX}), json!({"shape": id.0})] {+ refused(&mut s, p);+ }+ set_work_path(&mut s, Path::new(vec![Subpath::polygon(&[(0.0, 0.0), (200.0, 0.0), (200.0, 200.0)])]));+ s.execute("layer.setProps", json!({"layer": id.0, "locked": true})).unwrap();+ refused(&mut s, json!({}));+ }++ #[test]+ fn release_turns_area_type_into_box_text_over_the_path() {+ let mut s = session(8);+ let id = text_layer(&mut s, WORDS);+ set_work_path(&mut s, Path::new(vec![Subpath::polygon(&[(100.0, 100.0), (300.0, 100.0), (300.0, 250.0)])]));+ s.execute("type.fillPath", json!({})).unwrap();+ assert!(s.is_enabled("type.detachFromPath"));+ assert!(!s.is_enabled("type.convertToPointText") && !s.is_enabled("type.convertToParagraphText"));+ s.execute("type.detachFromPath", json!({})).unwrap();+ assert_eq!(text(&s, id).shape, TextShape::Box { x: 0.0, y: 0.0, width: 200.0, height: 150.0 });+ assert!(s.undo());+ assert!(matches!(text(&s, id).shape, TextShape::Area { .. }));+ }++ #[test]+ fn release_with_a_path_that_is_not_finite_is_an_error() {+ let mut s = session(8);+ let id = text_layer(&mut s, WORDS);+ // A file can carry any coordinates: one NaN or infinite point must not become a NaN text box.+ for bad in [f64::NAN, f64::INFINITY] {+ let path = Path::new(vec![Subpath::polygon(&[(0.0, 0.0), (100.0, bad), (100.0, 100.0)])]);+ s.edit("area", |doc, _| {+ if let Some(LayerContent::Text(t)) = doc.layer_mut(id).map(|l| &mut l.content) {+ t.shape = TextShape::Area { path };+ }+ Ok(())+ })+ .unwrap();+ assert!(s.execute("type.detachFromPath", json!({})).is_err(), "{bad}");+ assert!(matches!(text(&s, id).shape, TextShape::Area { .. }), "unchanged");+ }+ }++ #[test]+ fn area_type_saves_to_psd_as_paragraph_text_with_a_warning() {+ let mut s = session(8);+ text_layer(&mut s, WORDS);+ set_work_path(&mut s, Path::new(vec![Subpath::polygon(&[(100.0, 100.0), (300.0, 100.0), (300.0, 250.0), (100.0, 250.0)])]));+ s.execute("type.fillPath", json!({})).unwrap();+ let doc = s.active().unwrap().doc.clone();+ let r = photocraft_io::export(&doc, "x.psd", &photocraft_io::ExportOptions::default()).unwrap();+ assert!(r.warnings.iter().any(|w| w.contains("area type")), "{:?}", r.warnings);+ let back = photocraft_io::import("x.psd", &r.bytes).unwrap().document;+ let t = back.walk().into_iter().find_map(|(_, _, l)| match &l.content {+ LayerContent::Text(t) => Some(t.clone()),+ _ => None,+ });+ let t = t.expect("still a type layer");+ assert_eq!(t.text, WORDS);+ assert!(matches!(t.shape, TextShape::Box { width, height, .. } if (width - 200.0).abs() < 0.5 && (height - 150.0).abs() < 0.5), "{:?}", t.shape);+ }++ #[test]+ fn too_many_anchors_is_its_own_error() {+ // A ring of `n` smooth (curved) anchors around (200, 150).+ let ring = |n: usize| {+ let p = |a: f64, r: f64| photocraft_geom::Point::new(200.0 + r * a.cos(), 150.0 + r * a.sin());+ let step = std::f64::consts::TAU / n as f64;+ let knots = (0..n)+ .map(|i| {+ let a = i as f64 * step;+ let (anchor, d) = (p(a, 100.0), 100.0 * step / 3.0);+ let (tx, ty) = (-a.sin() * d, a.cos() * d);+ let at = |k: f64| photocraft_geom::Point::new(anchor.x + k * tx, anchor.y + k * ty);+ photocraft_doc::vector::Knot::smooth(anchor, at(-1.0), at(1.0))+ })+ .collect();+ Path::new(vec![Subpath { closed: true, knots, op: PathOp::Combine }])+ };+ let mut s = session(8);+ let id = text_layer(&mut s, WORDS);+ // Every anchor up to the limit fits, even with every segment curved.+ set_work_path(&mut s, ring(MAX_AREA_KNOTS));+ s.execute("type.fillPath", json!({})).unwrap();+ assert!(matches!(text(&s, id).shape, TextShape::Area { .. }));+ // One more is refused for what it is, not as a path that encloses nothing.+ let id = text_layer(&mut s, WORDS);+ set_work_path(&mut s, ring(MAX_AREA_KNOTS + 1));+ let e = s.execute("type.fillPath", json!({})).unwrap_err().to_string();+ assert!(e.contains("too many anchor points"), "{e}");+ assert_eq!(text(&s, id).shape, TextShape::Point);+ }++++/// Image Size with a new resolution keeps area type's pixel size (#7124), so its path grows in++/// text space with the font: the same words wrap onto the same lines, resampled or not.++#[test]++fn a_resolution_change_keeps_area_type_wrapping_where_it_was() {++ for (params, k) in [(json!({"resolution": 144, "resample": "none"}), 1), (json!({"width": 800, "height": 600, "resolution": 144}), 2)] {++ let mut s = session(8);++ let id = text_layer(&mut s, WORDS);++ set_work_path(&mut s, Path::new(vec![Subpath::polygon(&[(50.0, 50.0), (250.0, 50.0), (250.0, 200.0), (50.0, 200.0)])]));++ s.execute("type.fillPath", json!({})).unwrap();++ let lines = |s: &Session| {++ let d = &s.active().unwrap().doc;++ let mut eng = photocraft_text::shared().lock().unwrap_or_else(|e| e.into_inner());++ eng.layout(text(s, id), d.resolution_dpi).lines.iter().map(|l| l.range.clone()).collect::<Vec<_>>()++ };++ let size = |s: &Session| {++ let mut t = text(s, id).clone();++ crate::type_cmds::refresh(&s.active().unwrap().doc, &mut t);++ let b = t.cache.unwrap().content_bounds();++ (b.width(), b.height())++ };++ let (before, (w0, h0)) = (lines(&s), size(&s));++ assert!(before.len() >= 3, "{before:?}");++ s.execute("image.imageSize", params.clone()).unwrap();++ assert_eq!(lines(&s), before, "{params}");++ let (w, h) = size(&s);++ assert!(w.abs_diff(w0 * k) <= 3 && h.abs_diff(h0 * k) <= 3, "{params}: {w0}x{h0} -> {w}x{h}");++ }++}diff --cc crates/text/src/layout.rsindex 8ca0b6c2a,bf42fdc31..061f2ac67--- a/crates/text/src/layout.rs+++ b/crates/text/src/layout.rs@@@ -22,7 -22,7 +22,7 @@@ use parley::PositionedLayoutItem, StyleProperty,};use photocraft_doc::TextLayer;- use photocraft_doc::text::{Caps, CharStyle, FontBaseline, Kerning, Orientation, TextAlign, TextDirection, TextShape};-use photocraft_doc::text::{Caps, CharStyle, Kerning, Orientation, ParagraphStyle, TextAlign, TextDirection, TextShape};++use photocraft_doc::text::{Caps, CharStyle, FontBaseline, Kerning, Orientation, ParagraphStyle, TextAlign, TextDirection, TextShape};use skrifa::raw::types::Tag;use crate::fonts::FontDb;diff --cc crates/text/src/psd.rsindex 99fb2ebf0,72c46096e..d18e15d24--- a/crates/text/src/psd.rs+++ b/crates/text/src/psd.rs@@@ -1683,19 -1376,27 +1694,40 @@@ mod nonfinite_testsassert_eq!(char_style(None, &d, &[], 1.0).size_pt, 24.0);}+ /// #5645: `FontBaseline` (1 superscript, 2 subscript) is read and written back.+ #[test]+ fn font_baseline_round_trips() {+ use photocraft_doc::text::FontBaseline;+ let d = parse(b"<< /FontBaseline 2 >>").unwrap();+ assert_eq!(char_style(None, &d, &[], 1.0).baseline, FontBaseline::Subscript);+ let d = parse(b"<< /FontBaseline 1 >>").unwrap();+ assert_eq!(char_style(None, &d, &[], 1.0).baseline, FontBaseline::Superscript);+ let s = CharStyle { baseline: FontBaseline::Subscript, ..Default::default() };+ let back = char_style(None, &style_sheet_data(&s, 0, 1.0), &[], 1.0);+ assert_eq!(back.baseline, FontBaseline::Subscript);+ }++ #[test]+ fn area_path_that_is_not_finite_saves_as_point_text() {+ let path = photocraft_doc::vector::Path::new(vec![photocraft_doc::vector::Subpath::polygon(&[(0.0, 0.0), (f64::NAN, 0.0), (10.0, f64::INFINITY)])]);+ let layer = TextLayer {+ text: "x".into(),+ runs: vec![TextRun { len: 1, style: CharStyle { size_pt: 12.0, ..Default::default() } }],+ shape: TextShape::Area { path },+ ..Default::default()+ };+ let out = String::from_utf8_lossy(&crate::engine_data::write(&build_engine_data(&layer, None, 72.0))).into_owned();+ assert!(out.contains("/PointBase") && !out.contains("/BoxBounds"), "{out}");+ assert!(!out.to_ascii_lowercase().contains("nan") && !out.to_ascii_lowercase().contains("inf"), "{out}");+ let t = parse_tysh(&build_tysh(&layer, 72.0, None)).unwrap();+ for key in ["bounds", "boundingBox"] {+ let Some(D::Descriptor(d)) = t.text.get(key) else { panic!("no {key}") };+ for side in ["Left", "Top ", "Rght", "Btom"] {+ assert!(matches!(d.get(side), Some(D::UnitFloat { value, .. }) if value.is_finite()), "{key} {side}: {:?}", d.get(side));+ }+ }+ }+#[test]fn warp_values_beyond_f32_clamp_to_the_warp_range() {let warp = Descriptor::new("warp")diff --cc crates/text/src/tests.rsindex 6aecea05a,24b2d9cfc..1a3d3cd35--- a/crates/text/src/tests.rs+++ b/crates/text/src/tests.rs@@@ -2259,166 -2096,322 +2259,452 @@@ fn hyphenless_postscript_names_split_tr}}+#[test]+fn text_rebuild_preserves_imported_font_metadata() {+ use crate::engine_data::Value as E;+ let layer = point("Original", 24.0);+ let mut template = crate::psd::build_engine_data(&layer, None, 72.0);+ for key in ["ResourceDict", "DocumentResources"] {+ let fonts = template.get_mut(key).unwrap().get_mut("FontSet").unwrap();+ let E::Array(fonts) = fonts else { panic!("font array") };+ for font in fonts.iter_mut() {+ font.set("Script", E::Int(4));+ font.set("FontType", E::Int(2));+ font.set("Synthetic", E::Int(3));+ font.set("PrivateFontFlag", E::Int(17));+ }+ }+ let expected = template.path(&["ResourceDict", "FontSet"]).unwrap().clone();+ let mut edited = layer;+ edited.text = "Edited".into();+ let rebuilt = crate::psd::build_engine_data(&edited, Some(template), 72.0);+ for key in ["ResourceDict", "DocumentResources"] {+ assert_eq!(rebuilt.path(&[key, "FontSet"]), Some(&expected), "existing font metadata must survive a text edit");+ }+}++#[test]+fn font_metadata_survives_tysh_and_named_style_rewrites() {+ use crate::engine_data::Value as E;+ let source = point("Original", 24.0);+ let mut tysh = crate::psd::parse_tysh(&crate::psd::build_tysh(&source, 72.0, None)).unwrap();+ let mut data = crate::psd::engine_data(&tysh.text).unwrap();+ for (key, marker) in [("ResourceDict", 17), ("DocumentResources", 29)] {+ let E::Array(fonts) = data.get_mut(key).unwrap().get_mut("FontSet").unwrap() else { panic!("font array") };+ for font in fonts {+ font.set("PrivateFontFlag", E::Int(marker));+ font.set("Script", E::Int(4));+ }+ }+ for (key, value) in &mut tysh.text.items {+ if key.as_bytes() == b"EngineData" {+ *value = photocraft_psd::descriptor::Value::RawData(crate::engine_data::write(&data));+ }+ }+ let raw = crate::psd::write_tysh(&tysh);+ let mut imported = crate::psd::text_layer_from_tysh(&raw, 72.0).unwrap();+ // The IO importer retains the raw block separately from the parsed text model.+ imported.psd_raw = Some(raw.into());+ imported.text = "Edited".into();+ let rebuilt = crate::psd::build_tysh(&imported, 72.0, None);+ let styled = crate::psd_styles::write_style_sheets(&rebuilt, &imported, &photocraft_doc::TextStyles::default(), 72.0).unwrap();+ for bytes in [&rebuilt, &styled] {+ let parsed = crate::psd::parse_tysh(bytes).unwrap();+ let actual = crate::psd::engine_data(&parsed.text).unwrap();+ for key in ["ResourceDict", "DocumentResources"] {+ assert_eq!(actual.path(&[key, "FontSet"]), data.path(&[key, "FontSet"]));+ }+ assert_eq!(crate::psd::text_layer_from_tysh(bytes, 72.0).unwrap().text, "Edited");+ }+}++#[test]+fn font_metadata_append_reorder_and_duplicate_indices() {+ use crate::engine_data::Value as E;+ let record = |name: &str, marker| E::Dict(vec![("Name".into(), E::String(name.into())), ("PrivateFontFlag".into(), E::Int(marker))]);+ let entries = vec![record("A", 1), record("A", 2), record("B", 3)];+ let original = E::Array(entries.clone());+ let names = ["A", "A", "B", "New"].map(str::to_string);+ let result = crate::psd::font_set(&names, Some(&original));+ let fonts = result.as_array().unwrap();+ assert_eq!(&fonts[..3], entries.as_slice());+ assert_eq!(fonts[3], crate::psd::font_entry("New"));+ let reordered = crate::psd::font_set(&["B".into(), "A".into()], Some(&original));+ assert_eq!(reordered, E::Array(vec![entries[2].clone(), entries[1].clone()]));+ // A non-positional duplicate uses the first matching record, not the last map insertion.+ let fallback = crate::psd::font_set(&["New".into(), "B".into(), "A".into()], Some(&original));+ assert_eq!(fallback, E::Array(vec![crate::psd::font_entry("New"), entries[2].clone(), entries[0].clone()]));+ let empty = record("", 9);+ assert_eq!(crate::psd::font_set(&["".into()], Some(&E::Array(vec![E::Int(0), empty.clone()]))), E::Array(vec![empty]));+ for malformed in [None, Some(&E::Int(0))] {+ assert_eq!(crate::psd::font_set(&["New".into()], malformed), E::Array(vec![crate::psd::font_entry("New")]));+ }+}++#[test]+fn font_metadata_large_nameless_lists_rebuild_after_edit() {+ use crate::engine_data::Value as E;+ let mut layer = point("Original", 24.0);+ let mut template = crate::psd::build_engine_data(&layer, None, 72.0);+ for key in ["ResourceDict", "DocumentResources"] {+ template.get_mut(key).unwrap().set("FontSet", E::Array(vec![E::Int(0); 10_000]));+ }+ layer.text = "Edited".into();+ let rebuilt = crate::psd::build_engine_data(&layer, Some(template), 72.0);+ for key in ["ResourceDict", "DocumentResources"] {+ let fonts = rebuilt.path(&[key, "FontSet"]).unwrap().as_array().unwrap();+ assert!(fonts.len() >= 10_000);+ assert!(fonts[..10_000].iter().all(|font| *font == crate::psd::font_entry("")));+ }+}++/// Same-runner release probe: compare the original and repaired source, not a wall-clock CI limit.+#[test]+#[ignore = "release performance measurement for large imported FontSets"]+fn font_metadata_large_lists_timing() {+ use crate::engine_data::Value as E;+ for reordered in [false, true] {+ let mut layer = point("Original", 24.0);+ let mut template = crate::psd::build_engine_data(&layer, None, 72.0);+ let n = 100_000;+ for key in ["ResourceDict", "DocumentResources"] {+ let entries = if reordered {+ (0..n).map(|i| crate::psd::font_entry(&format!("Font{}", if key == "DocumentResources" { n - 1 - i } else { i }))).collect()+ } else {+ vec![E::Int(0); n]+ };+ template.get_mut(key).unwrap().set("FontSet", E::Array(entries));+ }+ layer.text = "Edited".into();+ let mut times = Vec::new();+ for _ in 0..3 {+ let input = template.clone();+ let start = std::time::Instant::now();+ let result = crate::psd::build_engine_data(&layer, Some(input), 72.0);+ std::hint::black_box(&result);+ times.push(start.elapsed().as_secs_f64());+ }+ times.sort_by(f64::total_cmp);+ println!("FONT_LOOKUP reordered={reordered} n={n} median_seconds={}", times[1]);+ }+}++/// A word wider than its paragraph box wraps at the box edge instead of running past it (#6694);+/// a normal break opportunity still wins, and a box that fits the word lays out exactly as before.+#[test]+fn a_word_wider_than_the_paragraph_box_breaks_at_the_box_edge() {+ let mut e = TextEngine::new();+ let word = "BLOQUEADO?!";+ let alone = e.layout(&point(word, 12.0), 72.0);+ assert_eq!(alone.lines.len(), 1, "{:?}", alone.lines);+ let word_width = width(&alone);+ let narrow = 30.0;+ assert!(word_width > narrow * 2.0, "{word_width}");++ let mut t = point(word, 12.0);+ t.shape = TextShape::Box { x: 0.0, y: 0.0, width: narrow, height: 200.0 };+ let l = e.layout(&t, 72.0);+ assert!(l.lines.len() >= 2, "{:?}", l.lines);+ for line in &l.lines {+ assert!(line.x1 <= narrow + 0.5, "{line:?}");+ }+ let joined: String = l.lines.iter().map(|l| &word[l.range.clone()]).collect();+ assert_eq!(joined, word);++ t.shape = TextShape::Box { x: 0.0, y: 0.0, width: word_width + 20.0, height: 200.0 };+ let fits = e.layout(&t, 72.0);+ assert_eq!(fits.lines.len(), 1, "{:?}", fits.lines);+ assert!((width(&fits) - word_width).abs() < 0.01, "{} vs {word_width}", width(&fits));++ let mut spaced = point("ab cd", 12.0);+ spaced.shape = TextShape::Box { x: 0.0, y: 0.0, width: narrow, height: 200.0 };+ let l = e.layout(&spaced, 72.0);+ assert_eq!(l.lines.len(), 2, "{:?}", l.lines);+ assert_eq!(l.lines[1].range.start, 3, "{:?}", l.lines);+}+++ /// Closed polygon in text space.+ fn area_poly(pts: &[(f64, f64)]) -> photocraft_doc::vector::Path {+ photocraft_doc::vector::Path::new(vec![photocraft_doc::vector::Subpath::polygon(pts)])+ }++ /// An ellipse from four kappa curves inside `[x, y, w, h]`.+ fn area_ellipse(x: f64, y: f64, w: f64, h: f64) -> photocraft_doc::vector::Path {+ use photocraft_doc::vector::{Knot, Subpath};+ use photocraft_geom::Point;+ let (rx, ry, cx, cy) = (w / 2.0, h / 2.0, x + w / 2.0, y + h / 2.0);+ let (kx, ky) = (0.552_284_75 * rx, 0.552_284_75 * ry);+ let p = Point::new;+ let knots = vec![+ Knot::smooth(p(cx, y), p(cx - kx, y), p(cx + kx, y)),+ Knot::smooth(p(x + w, cy), p(x + w, cy - ky), p(x + w, cy + ky)),+ Knot::smooth(p(cx, y + h), p(cx + kx, y + h), p(cx - kx, y + h)),+ Knot::smooth(p(x, cy), p(x, cy + ky), p(x, cy - ky)),+ ];+ photocraft_doc::vector::Path::new(vec![Subpath { closed: true, knots, op: Default::default() }])+ }++ const BUBBLE_TEXT: &str = "Well, that went better than expected. Now where did the cat hide the keys this time?";++ /// Every laid-out line sits inside a span of the shape across its band.+ fn assert_lines_inside(l: &crate::TextLayout, path: &photocraft_doc::vector::Path) {+ let a = crate::area::AreaShape::new(path, false).unwrap();+ for line in &l.lines {+ let spans = a.spans(line.baseline - line.ascent, line.baseline + line.descent, 0.0);+ assert!(spans.iter().any(|&(s0, s1)| line.x0 >= s0 - 0.5 && line.x1 <= s1 + 0.5), "{line:?} not inside {spans:?}");+ }+ }++ #[test]+ fn area_text_stays_inside_an_ellipse() {+ let mut e = TextEngine::new();+ let mut t = point(BUBBLE_TEXT, 18.0);+ let path = area_ellipse(0.0, 0.0, 260.0, 160.0);+ t.shape = TextShape::Area { path: path.clone() };+ let l = e.layout(&t, 72.0);+ assert!(l.lines.len() >= 4, "{}", l.lines.len());+ assert_lines_inside(&l, &path);+ // The top of an ellipse is too narrow for a line at its very edge: the first line starts lower.+ assert!(l.lines[0].baseline - l.lines[0].ascent > 1.0, "{:?}", l.lines[0]);+ // Lines go down the shape in text order.+ for w in l.lines.windows(2) {+ assert!(w[1].baseline >= w[0].baseline && w[1].range.start >= w[0].range.end, "{w:?}");+ }+ // Middle lines are wider than the first (the ellipse is widest in the middle).+ let width = |i: usize| l.lines[i].x1 - l.lines[i].x0;+ assert!(width(l.lines.len() / 2) > width(0), "{l:?}");+ }++ #[test]+ fn area_overflow_is_hidden() {+ let mut e = TextEngine::new();+ let mut t = point(&BUBBLE_TEXT.repeat(10), 14.0);+ let path = area_ellipse(0.0, 0.0, 200.0, 80.0);+ t.shape = TextShape::Area { path: path.clone() };+ let l = e.layout(&t, 72.0);+ assert!(!l.lines.is_empty());+ assert!(l.lines.last().unwrap().range.end < t.text.len(), "the rest is hidden");+ assert_lines_inside(&l, &path);+ }++ /// A long word that reaches the narrow bottom of a full bubble is hidden with the rest, not+ /// drawn past the outline: the wide middle rows would hold it, so the shape just ran out.+ #[test]+ fn area_overflow_at_the_narrow_bottom_is_hidden() {+ let mut e = TextEngine::new();+ let words = "Unfortunately the misunderstanding between representatives continued indefinitely. ";+ for (w, h, size) in [(260.0, 160.0, 12.0), (180.0, 140.0, 14.0), (150.0, 220.0, 12.0)] {+ let mut t = point(&words.repeat(8), size);+ let path = area_ellipse(0.0, 0.0, w, h);+ t.shape = TextShape::Area { path: path.clone() };+ let l = e.layout(&t, 72.0);+ assert!(!l.lines.is_empty());+ assert!(l.lines.last().unwrap().range.end < t.text.len(), "the rest is hidden");+ assert_lines_inside(&l, &path);+ }+ }++ /// The same in a later paragraph: its own rows start below the wide top of the shape, but the+ /// shape would still hold the word there, so it is hidden rather than drawn past the outline.+ #[test]+ fn area_overflow_in_a_later_paragraph_is_hidden() {+ let mut e = TextEngine::new();+ // A funnel: 300 px wide at the top, a point at the bottom.+ let path = area_poly(&[(0.0, 0.0), (300.0, 0.0), (150.0, 300.0)]);+ for n in (10..120).step_by(5) {+ let text = format!("{}\nmisunderstanding and more", "cat ".repeat(n));+ let mut t = point(&text, 12.0);+ t.shape = TextShape::Area { path: path.clone() };+ let l = e.layout(&t, 72.0);+ assert_lines_inside(&l, &path);+ }+ }++ #[test]+ fn area_lines_center_in_their_span() {+ let mut e = TextEngine::new();+ let mut t = point(BUBBLE_TEXT, 12.0);+ t.paragraphs = vec![ParagraphRun { len: t.text.len(), style: ParagraphStyle { align: TextAlign::Center, ..Default::default() } }];+ // A diamond: every row's span is centred on x = 100.+ t.shape = TextShape::Area { path: area_poly(&[(100.0, 0.0), (200.0, 100.0), (100.0, 200.0), (0.0, 100.0)]) };+ let l = e.layout(&t, 72.0);+ assert!(l.lines.len() >= 3);+ for line in &l.lines {+ assert!(((line.x0 + line.x1) / 2.0 - 100.0).abs() < 1.5, "{line:?}");+ }+ }++ /// Horizontal scale applies after shaping, so area lines break at the span width divided by it:+ /// widened text stays inside the shape and centred lines stay centred (#5565).+ #[test]+ fn horizontally_scaled_area_text_stays_inside_its_spans() {+ let mut e = TextEngine::new();+ let style = CharStyle { font_family: "Inter".into(), size_pt: 12.0, horizontal_scale: 1.5, ..Default::default() };+ let mut t = styled(BUBBLE_TEXT, style);+ let path = area_ellipse(0.0, 0.0, 240.0, 200.0);+ t.shape = TextShape::Area { path: path.clone() };+ let l = e.layout(&t, 72.0);+ assert!(l.lines.len() >= 3, "{:?}", l.lines);+ assert_lines_inside(&l, &path);+ t.paragraphs = vec![ParagraphRun { len: t.text.len(), style: ParagraphStyle { align: TextAlign::Center, ..Default::default() } }];+ t.shape = TextShape::Area { path: area_poly(&[(100.0, 0.0), (200.0, 100.0), (100.0, 200.0), (0.0, 100.0)]) };+ let l = e.layout(&t, 72.0);+ assert!(l.lines.len() >= 2, "{:?}", l.lines);+ for line in &l.lines {+ assert!(((line.x0 + line.x1) / 2.0 - 100.0).abs() < 1.5, "{line:?}");+ }+ }++ #[test]+ fn area_rows_split_around_a_hole() {+ use photocraft_doc::vector::{PathOp, Subpath};+ let mut e = TextEngine::new();+ let mut t = point(&BUBBLE_TEXT.repeat(6), 12.0);+ let path = photocraft_doc::vector::Path::new(vec![+ Subpath::polygon(&[(0.0, 0.0), (300.0, 0.0), (300.0, 300.0), (0.0, 300.0)]),+ Subpath::polygon(&[(120.0, 100.0), (180.0, 100.0), (180.0, 200.0), (120.0, 200.0)]).with_op(PathOp::Subtract),+ ]);+ t.shape = TextShape::Area { path: path.clone() };+ let l = e.layout(&t, 72.0);+ assert_lines_inside(&l, &path);+ // Some baseline carries two lines: one left of the hole, one right of it, left first.+ let w = l.lines.windows(2).find(|w| (w[0].baseline - w[1].baseline).abs() < 1e-3).expect("a row split around the hole");+ let (left, right) = (&w[0], &w[1]);+ assert!(left.x1 <= 120.5 && right.x0 >= 179.5, "{left:?} {right:?}");+ }++ #[test]+ fn vertical_area_text_stays_inside() {+ use photocraft_doc::text::Orientation;+ let mut e = TextEngine::new();+ let mut t = point(BUBBLE_TEXT, 12.0);+ t.orientation = Orientation::Vertical;+ t.shape = TextShape::Area { path: area_poly(&[(0.0, 0.0), (120.0, 0.0), (120.0, 200.0), (0.0, 200.0)]) };+ let l = e.layout(&t, 72.0);+ assert!(l.lines.len() >= 2, "several columns");+ for g in &l.glyphs {+ assert!(g.x > -1.0 && g.x < 121.0 && g.y > -1.0 && g.y < 201.0, "{g:?}");+ }+ }++ #[test]+ fn area_without_room_lays_out_nothing_and_a_bad_path_lays_out_as_point_text() {+ let mut e = TextEngine::new();+ let mut t = point("Hello", 40.0);+ // 10 px tall: no 40 pt line fits.+ t.shape = TextShape::Area { path: area_poly(&[(0.0, 0.0), (300.0, 0.0), (300.0, 10.0), (0.0, 10.0)]) };+ assert!(e.layout(&t, 72.0).lines.is_empty());+ // An open path encloses nothing (only reachable from a hostile file): point text, no panic.+ t.shape = TextShape::Area { path: photocraft_doc::vector::Path::new(vec![photocraft_doc::vector::Subpath::polyline(&[(0.0, 0.0), (9.0, 9.0)])]) };+ let point_layout = e.layout(&point("Hello", 40.0), 72.0);+ assert_eq!(e.layout(&t, 72.0).lines.len(), point_layout.lines.len());+ }++ #[test]+ fn area_word_wider_than_every_span_overflows_instead_of_hiding_the_text() {+ use photocraft_doc::vector::Subpath;+ let mut e = TextEngine::new();+ // Two 40 px columns 120 px apart: their bounding box is 200 px wide, but no span is wider+ // than 40 px, so no row can ever hold the long word.+ let mut t = point("Wonderfulness is a long word", 12.0);+ let path = photocraft_doc::vector::Path::new(vec![+ Subpath::polygon(&[(0.0, 0.0), (40.0, 0.0), (40.0, 200.0), (0.0, 200.0)]),+ Subpath::polygon(&[(160.0, 0.0), (200.0, 0.0), (200.0, 200.0), (160.0, 200.0)]),+ ]);+ t.shape = TextShape::Area { path };+ let l = e.layout(&t, 72.0);+ let first = l.lines.first().expect("the text is shown");+ // The word overflows its 40 px span on the first row (box text would break it, #6694).+ assert!(first.x1 - first.x0 > 40.0 && first.x1 - first.x0 < 200.0, "{first:?}");+ assert!(first.x0 >= -0.5, "{first:?}");+ // Nothing is hidden.+ assert_eq!(l.lines.last().map(|line| line.range.end), Some(t.text.len()), "{:?}", l.lines);+ }++ #[test]+ fn single_size_area_paragraph_breaks_in_one_pass() {+ let mut e = TextEngine::new();+ let mut t = point(BUBBLE_TEXT, 12.0);+ t.shape = TextShape::Area { path: area_poly(&[(0.0, 0.0), (300.0, 0.0), (300.0, 300.0), (0.0, 300.0)]) };+ crate::layout::AREA_PASSES.with(|c| c.set(0));+ let l = e.layout(&t, 72.0);+ assert!(l.lines.len() >= 2);+ // Rows are planned with the paragraph's real metrics: no re-plan and no skipped spans.+ assert_eq!(crate::layout::AREA_PASSES.with(|c| c.get()), 1);+ }++ #[test]+ fn area_word_skips_a_narrow_span_for_a_wider_one_on_the_same_row() {+ let mut e = TextEngine::new();+ let mut t = point("Wonderful things happen in speech bubbles every single day.", 12.0);+ // A U: a 24 px left arm and a wide right arm above y = 150, joined below it.+ let path = area_poly(&[(0.0, 0.0), (24.0, 0.0), (24.0, 150.0), (80.0, 150.0), (80.0, 0.0), (300.0, 0.0), (300.0, 200.0), (0.0, 200.0)]);+ t.shape = TextShape::Area { path: path.clone() };+ let l = e.layout(&t, 72.0);+ assert_lines_inside(&l, &path);+ let first = l.lines.first().expect("the text is shown");+ // "Wonderful" is wider than the left arm: it starts the text in the right arm, on the first+ // row, and nothing is put in the left arm's span on that row.+ assert_eq!(first.range.start, 0);+ assert!(first.x0 >= 79.5, "{first:?}");+ assert!(first.baseline < 30.0, "first row: {first:?}");+ assert_eq!(l.lines.iter().filter(|line| (line.baseline - first.baseline).abs() < 1e-3).count(), 1, "{:?}", l.lines);+ assert_eq!(l.lines.last().map(|line| line.range.end), Some(t.text.len()), "nothing hidden");+ }++ #[test]+ fn area_stacks_paragraphs_with_leading_and_space_before() {+ let mut e = TextEngine::new();+ let text = "First paragraph of the bubble text.\nSecond paragraph goes right after it.";+ let mut t = point(text, 12.0);+ let style = ParagraphStyle { space_before_pt: 6.0, ..Default::default() };+ let leading = style.auto_leading * 12.0;+ t.paragraphs = vec![ParagraphRun { len: text.len(), style }];+ let path = area_poly(&[(0.0, 0.0), (120.0, 0.0), (120.0, 300.0), (0.0, 300.0)]);+ t.shape = TextShape::Area { path: path.clone() };+ let l = e.layout(&t, 72.0);+ assert_lines_inside(&l, &path);+ let (p0, p1): (Vec<_>, Vec<_>) = l.lines.iter().partition(|line| line.paragraph == 0);+ assert!(p0.len() >= 2 && p1.len() >= 2, "both paragraphs wrap: {:?}", l.lines);+ assert!(p1.iter().all(|line| line.paragraph == 1));+ // The second paragraph starts right after the break, one leading plus space before lower.+ let second = text.find('\n').unwrap() + 1;+ assert_eq!(p1[0].range.start, second);+ let gap = p1[0].baseline - p0.last().unwrap().baseline;+ assert!((gap - (leading + 6.0)).abs() < 1.0, "gap {gap}, want {}", leading + 6.0);+ // Lines within a paragraph are one leading apart.+ for w in p0.windows(2) {+ assert!((w[1].baseline - w[0].baseline - leading).abs() < 1.0, "{w:?}");+ }+ assert_eq!(l.lines.last().map(|line| line.range.end), Some(text.len()));+ }++ #[test]+ fn area_justify_fills_each_span_but_the_last_line() {+ let mut e = TextEngine::new();+ let mut t = point(&BUBBLE_TEXT.repeat(2), 12.0);+ t.paragraphs = vec![ParagraphRun { len: t.text.len(), style: ParagraphStyle { align: TextAlign::JustifyLeft, ..Default::default() } }];+ let path = area_ellipse(0.0, 0.0, 260.0, 160.0);+ t.shape = TextShape::Area { path: path.clone() };+ let l = e.layout(&t, 72.0);+ assert!(l.lines.len() >= 4, "{}", l.lines.len());+ assert_lines_inside(&l, &path);+ let a = crate::area::AreaShape::new(&path, false).unwrap();+ let span_of = |line: &crate::LineInfo| {+ a.spans(line.baseline - line.ascent, line.baseline + line.descent, 0.0)+ .into_iter()+ .find(|&(s0, s1)| line.x0 >= s0 - 0.5 && line.x1 <= s1 + 0.5)+ .unwrap()+ };+ let (last, rest) = l.lines.split_last().unwrap();+ for line in rest {+ // Justified: the glyphs run from one edge of the line's span to the other.+ let (s0, s1) = span_of(line);+ let ink = l.glyphs.iter().filter(|g| (g.y - line.baseline).abs() < 1e-3).map(|g| g.x).fold(f32::MIN, f32::max);+ assert!((line.x0 - s0).abs() < 1.0, "{line:?} in {s0}..{s1}");+ assert!(ink > s1 - 12.0, "last glyph at {ink}, span ends {s1}: {line:?}");+ }+ // The last line is set flush left, not stretched.+ let (s0, s1) = span_of(last);+ assert!((last.x0 - s0).abs() < 1.0 && last.x1 < s1 - 12.0, "{last:?} in {s0}..{s1}");+ }--/// A word wider than its paragraph box wraps at the box edge instead of running past it (#6694);-/// a normal break opportunity still wins, and a box that fits the word lays out exactly as before.-#[test]-fn a_word_wider_than_the_paragraph_box_breaks_at_the_box_edge() {- let mut e = TextEngine::new();- let word = "BLOQUEADO?!";- let alone = e.layout(&point(word, 12.0), 72.0);- assert_eq!(alone.lines.len(), 1, "{:?}", alone.lines);- let word_width = width(&alone);- let narrow = 30.0;- assert!(word_width > narrow * 2.0, "{word_width}");-- let mut t = point(word, 12.0);- t.shape = TextShape::Box { x: 0.0, y: 0.0, width: narrow, height: 200.0 };- let l = e.layout(&t, 72.0);- assert!(l.lines.len() >= 2, "{:?}", l.lines);- for line in &l.lines {- assert!(line.x1 <= narrow + 0.5, "{line:?}");- }- let joined: String = l.lines.iter().map(|l| &word[l.range.clone()]).collect();- assert_eq!(joined, word);-- t.shape = TextShape::Box { x: 0.0, y: 0.0, width: word_width + 20.0, height: 200.0 };- let fits = e.layout(&t, 72.0);- assert_eq!(fits.lines.len(), 1, "{:?}", fits.lines);- assert!((width(&fits) - word_width).abs() < 0.01, "{} vs {word_width}", width(&fits));-- let mut spaced = point("ab cd", 12.0);- spaced.shape = TextShape::Box { x: 0.0, y: 0.0, width: narrow, height: 200.0 };- let l = e.layout(&spaced, 72.0);- assert_eq!(l.lines.len(), 2, "{:?}", l.lines);- assert_eq!(l.lines[1].range.start, 3, "{:?}", l.lines);-}diff --cc crates/ui-egui/src/type_tool.rsindex 0b7ba0e15,b3b1ec85d..b4727f9c5--- a/crates/ui-egui/src/type_tool.rs+++ b/crates/ui-egui/src/type_tool.rs@@@ -2374,18 -2465,6 +2476,21 @@@ fn type_sections(app: &mut PhotocraftAp("justifyAll", tl!("Justify all"), A::JustifyAll),];let cw = cell_width(full, items.len());- // Justification needs a paragraph box: on point text Photoshop greys the four justify- // buttons (#7713).++ // Justification needs a paragraph box or area type: on point text Photoshop greys the four++ // justify buttons (#7713).+ // The panel formats the layer being typed in, else every selected type layer.+ let point = match formatting_params(app) {+ Some(p) => p.get("layers").and_then(serde_json::Value::as_array).map_or_else(+ || p.get("layer").and_then(serde_json::Value::as_u64).into_iter().collect::<Vec<_>>(),+ |ids| ids.iter().filter_map(serde_json::Value::as_u64).collect(),+ ),+ None => Vec::new(),+ }+ .into_iter()- .any(|layer| box_shape(app, LayerId(layer)).is_none());++ .any(|layer| {++ let shape = app.session.active().and_then(|s| text_layer(&s.doc, LayerId(layer)).map(|t| t.shape.clone()));++ !matches!(shape, Some(photocraft_doc::text::TextShape::Box { .. } | photocraft_doc::text::TextShape::Area { .. }))++ });ui.horizontal(|ui| {ui.spacing_mut().item_spacing.x = 2.0;for (key, tip, a) in items {diff --cc crates/ui-egui/src/type_tool_tests.rsindex 1736efee5,1377ea573..3ca33b97f--- a/crates/ui-egui/src/type_tool_tests.rs+++ b/crates/ui-egui/src/type_tool_tests.rs@@@ -2238,51 -2163,146 +2238,219 @@@ fn type_mask_shift_adds_and_alt_subtracassert!(at(&app, 1050, 150) > 0.99, "and keeps the rest");}+/// #7713: justification needs a paragraph box. On point text the Paragraph panel's four justify+/// buttons are greyed, as in Photoshop; on paragraph text they work.+#[test]+fn justify_buttons_are_greyed_on_point_text() {+ use egui_kittest::kittest::{NodeT, Queryable};+ let justify = ["Justify last left", "Justify last centered", "Justify last right", "Justify all"];+ for (paragraph, enabled) in [(false, false), (true, true)] {+ let mut app = new_app();+ let mut p = json!({"text": "one two three four", "size": 24, "x": 300, "y": 420});+ if paragraph {+ p["box"] = json!([300, 300, 240, 180]);+ }+ app.run("type.create", p).unwrap();+ let mut h = Harness::builder().with_size(vec2(320.0, 700.0)).build_ui_state(+ |ui, app: &mut PhotocraftApp| {+ if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) {+ crate::type_tool::character_panel(app, ui, true);+ }+ },+ app,+ );+ PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::ALL[0]);+ h.run_steps(4);+ for tip in justify {+ assert_eq!(!h.get_by_label(tip).accesskit_node().is_disabled(), enabled, "{tip} on {}", if paragraph { "paragraph text" } else { "point text" });+ }+ assert!(!h.get_by_label("Center text").accesskit_node().is_disabled(), "alignment itself stays available");+ }+ // A selection of a paragraph and a point type layer formats both: justify is greyed.+ let mut app = new_app();+ let point = app.run("type.create", json!({"text": "point", "size": 24, "x": 300, "y": 420})).unwrap()["layer"].as_u64().unwrap();+ let boxed =+ app.run("type.create", json!({"text": "boxed text", "size": 24, "x": 300, "y": 300, "box": [300, 300, 240, 180]})).unwrap()["layer"].as_u64().unwrap();+ app.run("layer.select", json!({"layer": point})).unwrap();+ app.run("layer.select", json!({"layer": boxed, "mode": "add"})).unwrap();+ assert_eq!(app.session.active().unwrap().selected_layers().len(), 2);+ let mut h = Harness::builder().with_size(vec2(320.0, 700.0)).build_ui_state(+ |ui, app: &mut PhotocraftApp| {+ if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) {+ crate::type_tool::character_panel(app, ui, true);+ }+ },+ app,+ );+ PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::ALL[0]);+ h.run_steps(4);+ assert!(h.get_by_label("Justify all").accesskit_node().is_disabled(), "one of the formatted layers is point text");+}+++ fn ellipse_layer(app: &mut PhotocraftApp) -> u64 {+ app.run("shape.create", json!({"kind": "ellipse", "rect": [200, 200, 400, 300], "fill": "#dddddd"})).unwrap()["layer"].as_u64().unwrap()+ }++ fn click_at(app: &mut PhotocraftApp, x: f64, y: f64) {+ use crate::canvas::{ToolEvent, tool_event};+ tool_event(app, ToolEvent::Down { x, y, pressure: 1.0 }, Modifiers::NONE);+ tool_event(app, ToolEvent::Up { x, y }, Modifiers::NONE);+ }++ #[test]+ fn clicking_inside_a_shape_starts_area_type_in_one_step() {+ use photocraft_doc::text::TextShape;+ let mut app = new_app();+ let shape = ellipse_layer(&mut app);+ assert!(matches!(path_target(&app, 400.0, 350.0), Some(PathClick::Area { shape: Some(s) }) if s == shape));+ let before = app.session.active().unwrap().history.entries().len();+ click_at(&mut app, 400.0, 350.0);+ let id = LayerId(app.ui.text_edit.as_ref().expect("editing").layer);+ let st = app.session.active().unwrap();+ assert!(matches!(text_layer(&st.doc, id).unwrap().shape, TextShape::Area { .. }));+ assert_eq!(st.history.entries().len(), before + 1, "create + fill is one step");+ super::commit(&mut app);+ app.run("edit.undo", json!({})).unwrap();+ assert!(app.session.active().unwrap().doc.layer(id).is_none());+ }++ #[test]+ fn clicking_on_a_path_outline_starts_type_on_the_path_where_clicked() {+ use photocraft_doc::text::TextShape;+ let mut app = new_app();+ ellipse_layer(&mut app);+ // The ellipse's bottom point (400, 500); its perimeter is about 1105 px.+ let Some(PathClick::OnPath { start, .. }) = path_target(&app, 400.0, 500.0) else { panic!("on the outline") };+ assert!((0.0..1110.0).contains(&start), "{start}");+ // A point a quarter of the way further round is about 276 px further along (mod the perimeter).+ let Some(PathClick::OnPath { start: right, .. }) = path_target(&app, 600.0, 350.0) else { panic!("on the outline") };+ let d = (right - start).rem_euclid(1105.0);+ assert!((d - 276.0).abs() < 15.0 || (d - 829.0).abs() < 15.0, "{start} → {right}");+ let before = app.session.active().unwrap().history.entries().len();+ click_at(&mut app, 400.0, 500.0);+ let id = LayerId(app.ui.text_edit.as_ref().unwrap().layer);+ assert_eq!(app.session.active().unwrap().history.entries().len(), before + 1, "create + attach is one step");+ assert!(+ matches!(text_layer(&app.session.active().unwrap().doc, id).unwrap().shape, TextShape::Path { start: s, .. } if (f64::from(s) - start).abs() < 0.01)+ );+ }++ #[test]+ fn click_outside_paths_still_makes_point_text() {+ use photocraft_doc::text::TextShape;+ let mut app = new_app();+ ellipse_layer(&mut app);+ assert!(path_target(&app, 1200.0, 700.0).is_none());+ click_at(&mut app, 1200.0, 700.0);+ let id = LayerId(app.ui.text_edit.as_ref().unwrap().layer);+ assert_eq!(text_layer(&app.session.active().unwrap().doc, id).unwrap().shape, TextShape::Point);+ // A drag inside the shape still makes a text box, as in Photoshop.+ let mut app = new_app();+ ellipse_layer(&mut app);+ use crate::canvas::{ToolEvent, tool_event};+ tool_event(&mut app, ToolEvent::Down { x: 300.0, y: 300.0, pressure: 1.0 }, Modifiers::NONE);+ tool_event(&mut app, ToolEvent::Move { x: 450.0, y: 400.0, pressure: 1.0 }, Modifiers::NONE);+ tool_event(&mut app, ToolEvent::Up { x: 450.0, y: 400.0 }, Modifiers::NONE);+ let id = LayerId(app.ui.text_edit.as_ref().unwrap().layer);+ assert!(matches!(text_layer(&app.session.active().unwrap().doc, id).unwrap().shape, TextShape::Box { .. }));+ }++ #[test]+ fn type_mask_tools_ignore_paths() {+ let mut app = new_app();+ ellipse_layer(&mut app);+ app.ui.tool = crate::state::Tool::HorizontalTypeMask;+ click_at(&mut app, 400.0, 350.0);+ let id = LayerId(app.ui.text_edit.as_ref().unwrap().layer);+ assert_eq!(text_layer(&app.session.active().unwrap().doc, id).unwrap().shape, photocraft_doc::text::TextShape::Point);+ }++ #[test]+ fn a_one_anchor_work_path_is_not_a_path_target() {+ // `type.attachToPath` needs a segment, so the pointer must not promise type on this path.+ let mut app = new_app();+ std::sync::Arc::make_mut(&mut app.session.active_mut().unwrap().doc).work_path =+ Some(photocraft_doc::Path::new(vec![photocraft_doc::Subpath::polyline(&[(500.0, 400.0)])]));+ assert!(path_target(&app, 500.0, 400.0).is_none());+ click_at(&mut app, 500.0, 400.0);+ let id = LayerId(app.ui.text_edit.as_ref().unwrap().layer);+ assert_eq!(text_layer(&app.session.active().unwrap().doc, id).unwrap().shape, photocraft_doc::text::TextShape::Point);+ }++ #[test]+ fn over_existing_type_on_a_shape_the_pointer_is_the_plain_i_beam_and_a_click_edits_it() {+ let mut app = new_app();+ let text = app.run("type.create", json!({"text": "Hello", "x": 330, "y": 370, "size": 36})).unwrap()["layer"].as_u64().unwrap();+ let shape = ellipse_layer(&mut app); // the shape layer is active, so its path is the target+ let layers = app.session.active().unwrap().doc.walk().len();+ let mut h = harness(1.0, app);+ let on_text = glyph(&mut h, LayerId(text), 1, 0.5);+ let [dx, dy] = xf(h.state()).to_doc(on_text);+ assert!(matches!(path_target(h.state(), dx, dy), Some(PathClick::Area { shape: Some(s) }) if s == shape), "the text sits inside the shape");+ h.hover_at(on_text);+ h.run_steps(2);+ assert_eq!(h.output().platform_output.cursor_icon, egui::CursorIcon::Text, "a click here edits the type, so the plain I-beam");+ // Inside the shape but away from the type: the area-type pointer (drawn, not the OS I-beam).+ let inside = xf(h.state()).to_screen(400.0, 250.0);+ h.hover_at(inside);+ h.run_steps(2);+ assert_ne!(h.output().platform_output.cursor_icon, egui::CursorIcon::Text, "area-type pointer inside the shape");+ click(&mut h, on_text);+ let app = h.state();+ assert_eq!(app.ui.text_edit.as_ref().expect("editing").layer, text, "the click edits the existing layer");+ assert_eq!(app.session.active().unwrap().doc.walk().len(), layers, "no new layer");+ assert_eq!(text_layer(&app.session.active().unwrap().doc, LayerId(text)).unwrap().shape, photocraft_doc::text::TextShape::Point);+ }++ #[test]+ fn paths_with_too_many_anchors_are_not_hover_targets() {+ // The hover hit-tests every segment each frame, so huge paths are skipped (click and pointer alike).+ let ring = |n: usize| -> Vec<(f64, f64)> {+ (0..n).map(|i| i as f64 / n as f64 * std::f64::consts::TAU).map(|a| (500.0 + 200.0 * a.cos(), 400.0 + 200.0 * a.sin())).collect()+ };+ let mut app = new_app();+ std::sync::Arc::make_mut(&mut app.session.active_mut().unwrap().doc).work_path =+ Some(photocraft_doc::Path::new(vec![photocraft_doc::Subpath::polygon(&ring(4000))]));+ assert!(matches!(path_target(&app, 500.0, 400.0), Some(PathClick::Area { shape: None })));+ std::sync::Arc::make_mut(&mut app.session.active_mut().unwrap().doc).work_path =+ Some(photocraft_doc::Path::new(vec![photocraft_doc::Subpath::polygon(&ring(5000))]));+ assert!(path_target(&app, 500.0, 400.0).is_none());+ }++ #[test]+ fn hidden_target_path_is_not_a_click_target() {+ // View › Show › Target Path off hides the path, so a click there makes plain point text.+ let mut app = new_app();+ std::sync::Arc::make_mut(&mut app.session.active_mut().unwrap().doc).work_path =+ Some(photocraft_doc::Path::new(vec![photocraft_doc::Subpath::polygon(&[(300.0, 300.0), (700.0, 300.0), (700.0, 500.0), (300.0, 500.0)])]));+ assert!(matches!(path_target(&app, 500.0, 400.0), Some(PathClick::Area { shape: None })));+ app.ui.view.show.target_path = false;+ assert!(path_target(&app, 500.0, 400.0).is_none(), "Target Path off");+ app.ui.view.show.target_path = true;+ app.ui.view.extras = false;+ assert!(path_target(&app, 500.0, 400.0).is_none(), "Extras off");+ }++++/// Area type is paragraph text too: the justify buttons work on it (#7713 greys them on point text).++#[test]++fn justify_buttons_work_on_area_type() {++ use egui_kittest::kittest::{NodeT, Queryable};++ let mut app = new_app();++ app.run("type.create", json!({"text": "one two three four five six", "size": 24, "x": 300, "y": 420})).unwrap();++ std::sync::Arc::make_mut(&mut app.session.active_mut().unwrap().doc).work_path =++ Some(photocraft_doc::Path::new(vec![photocraft_doc::Subpath::polygon(&[(300.0, 300.0), (600.0, 300.0), (600.0, 500.0), (300.0, 500.0)])]));++ app.run("type.fillPath", json!({})).unwrap();++ let mut h = Harness::builder().with_size(vec2(320.0, 700.0)).build_ui_state(++ |ui, app: &mut PhotocraftApp| {++ if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) {++ crate::type_tool::character_panel(app, ui, true);++ }++ },++ app,++ );++ PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::ALL[0]);++ h.run_steps(4);++ for tip in ["Justify last left", "Justify last centered", "Justify last right", "Justify all"] {++ assert!(!h.get_by_label(tip).accesskit_node().is_disabled(), "{tip} on area type");++ }++}diff --cc docs/gaps.mdindex c6078fa33,623a334d6..522d9df6b--- a/docs/gaps.md+++ b/docs/gaps.md@@@ -1,6 -1,6 +1,6 @@@# Where PhotoCraft falls short of Photoshop- > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-18 · **Change:** minor (G1: smart objects keep Photoshop's Cylinder warp, #4112; 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, #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) · **Target:** Adobe Photoshop 2026-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-18 · **Change:** minor (G8: area type (TYPE-218-10); 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) · **Target:** Adobe Photoshop 2026++> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-18 · **Change:** minor (G8: area type (TYPE-218-10); G1: smart objects keep Photoshop's Cylinder warp, #4112; 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, #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) · **Target:** Adobe Photoshop 2026Every known shortfall against Photoshop 2026 (27.11.0), one entry each, ranked by user impacton the way to beta. This is the work list agents pick from: take the highest-ranked entry that@@@ -86,16 -78,15 +86,17 @@@ what an agent can't finish alone- **Estimate:** 80–140 h.### G8. Type depth-- **Missing:** type on a path (TYPE-218-1), paragraph direction UI (TYPE-218-2), complex-script- fallback fonts and golden tests (TYPE-218-3), OpenType Numerals and Stylistic Sets submenus- (TYPE-218-5; the Character panel buttons landed 2026-10-11, #3752), live Warp Text preview- (TYPE-218-7, #2689), "rasterize and continue" for distort/perspective on type- (TYPE-218-9), 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).-- **Evidence:** scorecard Type (2026-10-15): 4 done, 4 partial, 2 missing. 2026-10-11: 2/3/4/5 clicks select+- **Missing:** type on a path beyond rigid glyph placement (TYPE-218-1 partial, #4365),+ paragraph direction UI (TYPE-218-2), complex-script fallback fonts and golden tests+ (TYPE-218-3), OpenType Numerals and Stylistic Sets submenus+ (TYPE-218-5; the Character panel buttons landed 2026-10-11, #3752), text free transform- (#2630). Done since the re-measure: manual and optical kerning with PSD round trip++ (#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+ with the layer's warp (TYPE-218-7, #2689).- - **Evidence:** scorecard Type: 5 done, 3 partial, 1 missing. 2026-10-11: 2/3/4/5 clicks select- word, line, paragraph and all text, with tests (TYPE-218-8, #3493). The Type tool froze the app for++- **Evidence:** scorecard Type: 5 done, 4 partial, 1 missing. 2026-10-11: 2/3/4/5 clicks select+ word, line, paragraph and all text, with tests (TYPE-218-8, #3493). 2026-10-15: area type, type+ inside a closed path or shape, with holes (TYPE-218-10). The Type tool froze the app for60 s on one macOS machine (#2518).- **Estimate:** 120–200 h.@@@ -289,13 -271,8 +290,14 @@@| Date | Change | Summary ||---|---|---|+| 2026-10-15 | minor | G1 / #5972 A1: render only provably constant-RGB `GdFl` noise fills; variable noise synthesis remains open || 2026-10-18 | minor | G9: with no selection, Copy takes fill and adjustment layers whole and Paste recreates them (#2344); UI-217-23 stays partial (a single pixel layer copies its pixels only); estimate unchanged |-| 2026-10-15 | minor | G8: area type: Type tool click inside a closed path or shape wraps text inside it (TYPE-218-10); Type tool click on a path's outline (TYPE-218-1); Type scorecard count refreshed to 4 done, 4 partial, 2 missing |+| 2026-10-15 | minor | G2: a cancelled 24 MP Gaussian Blur job stops within 44 ms max (P25, budget 200 ms; was about 400 ms), the uncancelled job about 40% faster; #6205 |+| 2026-10-15 | minor | G9: Animated Zoom preference takes effect (hold the Zoom tool to zoom continuously, #6210); prefs that do nothing 25 of 166; no estimate changed |+| 2026-10-16 | minor | G7: Content-Aware Move's live preview covers every selection the command takes (over 256 × 256: a coarse result solved scaled down, then the exact one); TOOL-213-4 done (#6680) |+| 2026-10-15 | minor | G9: Save in Background off saves in the foreground under a modal progress dialog (#6207); preferences that do nothing 25 → 24 of 169 |+| 2026-10-14 | minor | G1: PSD smart objects keep Transform Warp's Cylinder through Replace Contents, Relink, Edit Contents and re-saves (#4112) |++| 2026-10-15 | minor | G8: area type: Type tool click inside a closed path or shape wraps text inside it (TYPE-218-10); Type tool click on a path's outline (TYPE-218-1); Type scorecard 5 done, 4 partial, 1 missing || 2026-10-14 | minor | G1: a PSD smart object's filter mask shows when the file opens (Photoshop stores the filtered pixels unmasked); export stores them that way too; Photoshop-oracle floor 185 → 188 of 258 || 2026-10-13 | minor | G14: D90 image area measured (4288 × 2848 at (10, 10)); gap remains open || 2026-10-14 | minor | Corpus floors raised to the measured results of the CMYK, Lab, 32-bit, Levels, Threshold, Posterize, feather and pass-through fixes landed together: Photoshop-authored 165 → 185 of 258, io 146 → 148 of 170, psd-tools 242 → 249 of 309 |diff --cc docs/scorecard.mdindex 5a59aad2a,1ff5e0507..39d215bbd--- a/docs/scorecard.md+++ b/docs/scorecard.md@@@ -6,11 -6,11 +6,11 @@@ Generated by `cargo xtask scorecard` fr| Area | Done | Partial | Missing | Key numbers ||---|---:|---:|---:|---|-| [Performance](#performance) | 3 | 22 | 24 | 58 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 19 not run, 5 not measurable yet (baseline 2026-10-05) |-| [File compatibility](#file-compatibility) | 7 | 14 | 6 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 |-| [Tools](#tools) | 33 | 11 | 0 | |-| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 25 of 169 (target 0) |-| [Type](#type) | 4 | 4 | 2 | |+| [Performance](#performance) | 3 | 22 | 26 | 60 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 22 not run, 4 not measurable yet (baseline 2026-10-05) |+| [File compatibility](#file-compatibility) | 9 | 12 | 6 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 |+| [Tools](#tools) | 36 | 8 | 0 | |+| [Workspace and UI](#workspace-and-ui) | 13 | 7 | 3 | settings that do nothing: 24 of 171 (target 0) |- | [Type](#type) | 5 | 3 | 1 | |++| [Type](#type) | 5 | 4 | 1 | || [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) || [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 30 of 30 crates; panic_hunt present || [Distribution](#distribution) | 5 | 4 | 2 | |@@@ -221,9 -219,10 +221,10 @@@ Unread: `general.color_picker`, `genera| TYPE-218-4 | Variable font axis sliders from the font's axes; opsz follows the point size | done | [#218](https://github.com/storytold/photocraft/issues/218) | One slider per axis of the style's font in the Character section (Properties and Window > Character), setting type.setStyle variations; opsz follows the type size unless set (layout.rs variation_list); a style or weight resets the wght axis (#2985). PSD does not round-trip axis values yet || TYPE-218-5 | OpenType UI: Character panel buttons, Numerals and Stylistic Sets submenus | partial | [#218](https://github.com/storytold/photocraft/issues/218) | Type > OpenType toggles (type_extra_cmds.rs:512). Character panel (and the Properties Character section) has Photoshop's eight OpenType buttons: Standard Ligatures, Contextual Alternates, Discretionary Ligatures, Swash, Stylistic Alternates, Titling Alternates, Ordinals, Fractions, pressed while the feature is on at the selection and dispatching the type.openType.* commands (type_tool.rs opentype_row; character_panel_opentype_buttons_toggle_and_show_the_feature, #3752). Still missing: the Numerals and Stylistic Sets submenus, and greying out features the font lacks || TYPE-218-6 | Manual pair kerning (Alt+arrows), optical kerning rendered, both round-trip PSD (#206) | done | [#218](https://github.com/storytold/photocraft/issues/218) | Alt+Left/Right at a collapsed caret kerns the pair (type_tool.rs kern_pair, 20 per step and 100 with Cmd; type_tool_alt_arrows_kern_the_pair). Optical kerning is computed from the glyph outlines in text/src/optical.rs and applied by layout.rs when the run's mode is Optical (optical_matches_photoshop, optical_kerning_tightens_open_pairs). Both modes and manual values round-trip through PSD (io/tests/psd_kerning.rs; the optical mode travels in Txt2, txt2_carries_optical_kerning) |-| TYPE-218-7 | Warp Text dialog previews live and opens with the layer's current warp | missing | [#218](https://github.com/storytold/photocraft/issues/218) | view_cmds.rs:834 always seeds arc, bend 50 |+| TYPE-218-7 | Warp Text dialog previews live and opens with the layer's current warp | done | [#218](https://github.com/storytold/photocraft/issues/218) | Type > Warp Text opens with the shown layer's warp, or None, never remembered values (filter_dialog.rs warp_defaults; warp_text_dialog_tests.rs warp_text_opens_with_the_type_layers_current_warp, warp_text_opens_at_none_for_a_layer_without_warp, remembered_warp_values_never_override_the_layers_warp). The dialog previews live without editing the document, Cancel leaves no step and OK is one undoable step (warp_text_dialog_previews_the_warp_without_editing_the_document, cancelling_warp_text_leaves_the_document_and_history_untouched, confirming_warp_text_is_one_undoable_step); the reduced-proxy preview matches the full-size result (filter_dialog.rs warp_text_preview_matches_the_full_size_result_on_a_reduced_proxy) || TYPE-218-8 | Text editing: select all, double/triple/quadruple-click selection, paste, with tests | done | [#218](https://github.com/storytold/photocraft/issues/218) | Like Photoshop, 2 clicks select the word, 3 the laid-out line (a column in vertical type), 4 the paragraph up to the hard return, 5 all text, and the next quick click starts over (#3493; type_tool.rs next_click_count, click_selection, multi_click). Tested through real canvas clicks in point, paragraph and vertical type, with paste replacing the selection and Cmd+A selecting all (type_tool_tests.rs multi_click_selects_word_line_paragraph_and_all_in_point_text, multi_click_separates_wrapped_lines_from_paragraphs, click_counts_cycle_and_restart, click_selection_without_layout_and_on_hostile_input, multi_click_without_a_session_does_nothing) || TYPE-218-9 | Distort/Perspective/Warp on live type as in Photoshop (was: offer 'Rasterize and continue?'; Photoshop doesn't prompt) | done | [#218](https://github.com/storytold/photocraft/issues/218) | Photoshop 2026 prompts for none of these: Edit › Transform › Warp on live type stays enabled with no rasterize prompt and offers only the warp styles (the mesh can't be dragged), so the type stays editable; Distort, Perspective and the split warps are greyed. PhotoCraft does the same: Warp on type commits the layer's Warp Text in one step (transform_tool.rs enter_type_warp, warp_cmds.rs warp_type_layer, #3004; warp_on_type_takes_a_style_and_keeps_the_type_editable), Distort/Perspective greyed (enable_rules.rs, #2701) |+ | TYPE-218-10 | Area type: Type tool click inside a closed path or shape wraps text inside it, holes and dents included, PSD round trip | partial | [#218](https://github.com/storytold/photocraft/issues/218) | TextShape::Area (doc text.rs) laid out line by line into the spans the path leaves (text area.rs, layout.rs break_area), type.fillPath (engine type_area_cmds.rs), released to box text by type.detachFromPath, area/path cursors and click-to-place (ui-egui type_tool.rs path_target), .pcraft round trip. Missing: PSD area type (saves as paragraph text over the path's bounds, with an export warning); mixed type sizes in one area paragraph space at its largest line; area type takes paths of at most 4096 anchors: beyond that a Type tool click makes point text (the pointer shows the plain I-beam), and type.fillPath refuses the path with "the path has too many anchor points" (type.attachToPath still takes a subpath of up to 100,000 anchors); a word too wide for every span in the shape overflows its span (box text breaks it at the edge, #6694); the first line starts about 0.24 em lower than in a text box of the same size; Photoshop area type in a PSD opens as box text; the area path has no handles to edit it after the type is placed |## Automationdiff --cc docs/target-app-parity.mdindex a2581c4b4,50f376e63..ff314305c--- a/docs/target-app-parity.md+++ b/docs/target-app-parity.md@@@ -1,6 -1,6 +1,6 @@@# PhotoCraft vs Adobe Photoshop: target-app parity- > **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-18 · **Change:** minor (Content-Aware Move live preview for every selection size, TOOL-213-4 done, #6680; retouching evidence: Pattern Stamp and Background Eraser draw live, only the Mixer Brush is left of TOOL-213-7; fill and adjustment layers copy and paste whole, UI-217-23 partial, #2344; shape layers take Density and Feather, TOOL-214-12 done, #5846; on-canvas corner radius widgets, TOOL-214-12; `.atn` import maps 112 events; Free Transform H/V skew fields; stale rows corrected against `main` and the scorecard, estimates unchanged; Photoshop Actions `.atn` load and save; 2026-10-10: Tilt-Shift measurements added; earlier the same day: major, full re-measure against Photoshop 2026 27.11.0; merged `parity-estimate.md` and the roadmap's honest assessment; stale missing-tool rows corrected: Color Replacement and Red Eye are live toolbar tools, Frame landed; percentages unchanged) · **Target:** Adobe Photoshop 2026-> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-18 · **Change:** minor (area type, TYPE-218-10 partial, Type scorecard 4 / 4 / 2; fill and adjustment layers copy and paste whole, UI-217-23 partial, #2344; on-canvas corner radius widgets, TOOL-214-12; `.atn` import maps 112 events; Free Transform H/V skew fields; stale rows corrected against `main` and the scorecard, estimates unchanged; Photoshop Actions `.atn` load and save; 2026-10-10: Tilt-Shift measurements added; earlier the same day: major, full re-measure against Photoshop 2026 27.11.0; merged `parity-estimate.md` and the roadmap's honest assessment; stale missing-tool rows corrected: Color Replacement and Red Eye are live toolbar tools, Frame landed; percentages unchanged) · **Target:** Adobe Photoshop 2026++> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-18 · **Change:** minor (area type, TYPE-218-10 partial, Type scorecard 5 / 4 / 1; Content-Aware Move live preview for every selection size, TOOL-213-4 done, #6680; retouching evidence: Pattern Stamp and Background Eraser draw live, only the Mixer Brush is left of TOOL-213-7; fill and adjustment layers copy and paste whole, UI-217-23 partial, #2344; shape layers take Density and Feather, TOOL-214-12 done, #5846; on-canvas corner radius widgets, TOOL-214-12; `.atn` import maps 112 events; Free Transform H/V skew fields; stale rows corrected against `main` and the scorecard, estimates unchanged; Photoshop Actions `.atn` load and save; 2026-10-10: Tilt-Shift measurements added; earlier the same day: major, full re-measure against Photoshop 2026 27.11.0; merged `parity-estimate.md` and the roadmap's honest assessment; stale missing-tool rows corrected: Color Replacement and Red Eye are live toolbar tools, Frame landed; percentages unchanged) · **Target:** Adobe Photoshop 2026The authoritative answer to "how close is PhotoCraft to Photoshop, and how much work is left". Theone-page summary is [`ROADMAP.md`](../ROADMAP.md); the ranked work list is [`gaps.md`](gaps.md);@@@ -566,8 -566,7 +566,9 @@@ See [method, raw measurements and repro| Date | Change | Summary ||---|---|---|| 2026-10-18 | minor | Layers: with no selection, Copy takes fill and adjustment layers whole and Paste recreates them (#2344); UI-217-23 stays partial; percentages unchanged |-| 2026-10-15 | minor | Type: area type, text wrapping inside a closed path or shape with holes and dents (TYPE-218-10, partial: PSD saves it as paragraph text); Type scorecard count refreshed to 4 done / 4 partial / 2 missing; Type figure (40%) and percentages unchanged |+| 2026-10-16 | minor | Content-Aware Move: live result preview for every selection the command takes (TOOL-213-4 done, #6680); percentages unchanged |+| 2026-10-15 | minor | Vector shapes: shape layers take Density and Feather (Properties › Masks), PSD and .pcraft round trip; TOOL-214-12 done (#5846); estimates unchanged |++| 2026-10-15 | minor | Type: area type, text wrapping inside a closed path or shape with holes and dents (TYPE-218-10, partial: PSD saves it as paragraph text); Type scorecard 5 done / 4 partial / 1 missing; Type figure (40%) and percentages unchanged || 2026-10-13 | minor | Vector shapes: on-canvas corner radius widgets on live rectangles (TOOL-214-12); estimates unchanged || 2026-10-13 | minor | Stale "missing tool" rows corrected against main: Color Replacement (`paint.colorReplacement`), Red Eye (`paint.redEye`) and Add/Delete Anchor Point (the Pen flyout) are live toolbar tools and Frame landed, so Art History Brush is the only tool still missing; percentages unchanged || 2026-10-12 | minor | Free Transform options bar H/V skew fields; percentages unchanged |