Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Type tool: click a path to start type on it (TYPE-218-1, #218)

zolyyc0faf7300cb8
diff --git a/contributors/people.toml b/contributors/people.toml
index 6f630a0c1..6dda48b4b 100644
--- a/contributors/people.toml
+++ b/contributors/people.toml
@@ -158,3 +158,7 @@ sync_github_name = false
[people.yeniufuklar-com]
real_name = "Ufuk Efe"
sync_github_name = true
+
+[people.zolyy]
+real_name = "Gall Zoltan"
+sync_github_name = false
diff --git a/crates/engine/src/type_extra_cmds.rs b/crates/engine/src/type_extra_cmds.rs
index efa2d791c..c63f7d3d7 100644
--- a/crates/engine/src/type_extra_cmds.rs
+++ b/crates/engine/src/type_extra_cmds.rs
@@ -368,13 +368,24 @@ fn attach_to_path(s: &mut Session, p: &Value) -> Result<Value> {
None | Some(Value::Null) => false,
Some(v) => v.as_bool().ok_or_else(|| bad("\"flip\" must be true or false"))?,
};
+ // A document point: the type starts where the path passes nearest it (the Type tool's click).
+ let at = match p.get("at") {
+ None | Some(Value::Null) => None,
+ Some(v) => {
+ let xy = v.as_array().filter(|a| a.len() == 2).and_then(|a| Some((a.first()?.as_f64()?, a.get(1)?.as_f64()?)));
+ Some(xy.filter(|(x, y)| x.is_finite() && y.is_finite()).ok_or_else(|| bad("\"at\" must be [x, y] in document pixels"))?)
+ }
+ };
+ if at.is_some() && p.get("start").is_some_and(|v| !v.is_null()) {
+ return Err(bad("pass \"start\" or \"at\", not both"));
+ }
let id = layer_param(s, p)?;
let doc = &s.active().ok_or(EngineError::NoDocument)?.doc;
if doc.effective_locks(id).all {
return Err(EngineError::Other("the type layer is locked".into()));
}
let sub = path_source(doc, p)?;
- with_text(s, p, "Type on a Path", |t, _| {
+ let start = with_text(s, p, "Type on a Path", |t, _| {
// The path lives in document space; the type layer keeps it in its own text space, so
// the type lands on the path where it is drawn.
let inv = t.transform.inverse().ok_or_else(|| EngineError::Other("the type layer's transform cannot be inverted".into()))?;
@@ -384,8 +395,15 @@ fn attach_to_path(s: &mut Session, p: &Value) -> Result<Value> {
if !path.knots.iter().all(|k| [k.anchor, k.in_ctrl, k.out_ctrl].iter().all(|q| q.x.is_finite() && q.y.is_finite())) {
return Err(EngineError::Other("the path cannot be mapped into the type layer".into()));
}
+ let start = match at {
+ None => start,
+ Some((x, y)) => {
+ let q = map(Point::new(x, y));
+ photocraft_text::warp::arc_length_at(&path, flip, q.x, q.y).ok_or_else(|| bad("the path has no length"))? as f32
+ }
+ };
t.shape = TextShape::Path { path, start, flip };
- Ok(())
+ Ok(start)
})?;
Ok(json!({"layer": id.0, "start": start, "flip": flip}))
}
@@ -696,7 +714,7 @@ pub fn specs() -> Vec<CommandSpec> {
"type.attachToPath",
"Type on a Path",
&[],
- r##"{"layer":id? (default active Type layer),"shape":layerId? (a shape layer; default the work path),"subpath":index=0,"start":px=0 (offset along the path),"flip":bool=false (run along the path the other way, on its other side)}"##,
+ r##"{"layer":id? (default active Type layer),"shape":layerId? (a shape layer; default the work path),"subpath":index=0,"start":px=0 (offset along the path),"at":[x,y]? (instead of "start": begin where the path passes nearest this document point, as a Type tool click does),"flip":bool=false (run along the path the other way, on its other side)}"##,
has_text,
attach_to_path
),
diff --git a/crates/engine/src/type_extra_cmds/tests.rs b/crates/engine/src/type_extra_cmds/tests.rs
index 9f604eed1..a2f7f734b 100644
--- a/crates/engine/src/type_extra_cmds/tests.rs
+++ b/crates/engine/src/type_extra_cmds/tests.rs
@@ -313,6 +313,34 @@ fn type_attaches_to_a_path_and_releases_it() {
assert!(matches!(text(&s, id).shape, TextShape::Path { .. }));
}
+/// The Type tool's click on a path: `"at"` starts the type where the path passes nearest the
+/// click, and the paragraph alignment is kept about that point, as in Photoshop.
+#[test]
+fn type_attaches_to_a_path_at_a_document_point() {
+ let mut s = session(8);
+ s.edit("path", |doc, _| {
+ doc.work_path = Some(Path::new(vec![Subpath::polyline(&[(10.0, 60.0), (290.0, 60.0)])]));
+ Ok(())
+ })
+ .unwrap();
+ for (align, centred) in [("left", false), ("center", true)] {
+ let r = s.execute("type.create", json!({"x": 150, "y": 60, "text": "Path", "size": 24, "align": align, "color": "#000000"})).unwrap();
+ let id = LayerId(r["layer"].as_u64().unwrap());
+ assert!(s.execute("type.attachToPath", json!({"at": [150, "y"]})).is_err());
+ assert!(s.execute("type.attachToPath", json!({"at": [150]})).is_err());
+ assert!(s.execute("type.attachToPath", json!({"at": [150, 60], "start": 3})).is_err());
+ let r = s.execute("type.attachToPath", json!({"at": [150, 64]})).unwrap();
+ assert!((r["start"].as_f64().unwrap() - 140.0).abs() < 0.5, "{r}");
+ let b = ink(&s, id);
+ assert!(b.y1 <= 61, "the type sits on the path: {b:?}");
+ if centred {
+ assert!(b.x0 < 145 && b.x1 > 155, "centred on the click: {b:?}");
+ } else {
+ assert!((148..=156).contains(&b.x0), "starts at the click: {b:?}");
+ }
+ }
+}
+
#[test]
fn all_locked_layer_rejects_paste_lorem_ipsum_without_history() {
// #4188: Lock All stopped type.edit (#3132) but not Paste Lorem Ipsum into the layer.
diff --git a/crates/text/src/warp.rs b/crates/text/src/warp.rs
index f148a18e1..439fc453b 100644
--- a/crates/text/src/warp.rs
+++ b/crates/text/src/warp.rs
@@ -110,6 +110,13 @@ impl Warp {
}
}
+/// The arc length along `path`, measured as type on it measures it (from the end it starts at
+/// with `flip`), of the point on the path nearest (`x`, `y`): the `start` that puts the type's
+/// origin where the Type tool clicked on the path. `None` for a path without length.
+pub fn arc_length_at(path: &Subpath, flip: bool, x: f64, y: f64) -> Option<f64> {
+ PathFrame::new(path, 0.0, flip).map(|f| f.project(x, y))
+}
+
/// Most cubic segments of a type path that are followed (a hostile file cannot make this large).
const MAX_PATH_SEGMENTS: usize = 4096;
@@ -163,6 +170,22 @@ impl PathFrame {
self.cum.last().copied().unwrap_or(0.0)
}
+ /// Arc length of the point on the flattened path nearest (`x`, `y`).
+ fn project(&self, x: f64, y: f64) -> f64 {
+ let mut best = (f64::INFINITY, 0.0);
+ for (i, w) in self.pts.windows(2).enumerate() {
+ let [a, b] = [w[0], w[1]];
+ let (dx, dy) = (b.0 - a.0, b.1 - a.1);
+ let len2 = dx * dx + dy * dy;
+ let t = if len2 > 0.0 { (((x - a.0) * dx + (y - a.1) * dy) / len2).clamp(0.0, 1.0) } else { 0.0 };
+ let d = (a.0 + dx * t - x).hypot(a.1 + dy * t - y);
+ if d < best.0 {
+ best = (d, self.cum.get(i).copied().unwrap_or(0.0) + len2.sqrt() * t);
+ }
+ }
+ best.1
+ }
+
/// Point and unit tangent at arc length `s`; past either end the end tangent continues straight.
fn at(&self, s: f64) -> ((f64, f64), (f64, f64)) {
let last = self.pts.len() - 1;
@@ -211,6 +234,18 @@ mod tests {
}
}
+ /// The Type tool's click on a path: the nearest point's arc length, from the other end with flip.
+ #[test]
+ fn arc_length_at_projects_onto_the_path() {
+ let line = Subpath::polyline(&[(0.0, 0.0), (100.0, 0.0), (100.0, 50.0)]);
+ let at = |flip, x, y| arc_length_at(&line, flip, x, y).unwrap();
+ assert!((at(false, 30.0, -8.0) - 30.0).abs() < 1e-6);
+ assert!((at(false, 110.0, 20.0) - 120.0).abs() < 1e-6, "on the second segment");
+ assert!((at(true, 30.0, -8.0) - 120.0).abs() < 1e-6, "flipped: measured from the far end");
+ assert!(at(false, -50.0, 0.0).abs() < 1e-6, "clamped to the start");
+ assert!(arc_length_at(&Subpath::polyline(&[(5.0, 5.0), (5.0, 5.0)]), false, 0.0, 0.0).is_none());
+ }
+
#[test]
fn styles_resolve_and_none_is_identity() {
assert_eq!(psd_style("Arc"), Some("warpArc"));
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs
index db0efe31f..27ea38325 100644
--- a/crates/ui-egui/src/canvas.rs
+++ b/crates/ui-egui/src/canvas.rs
@@ -3884,6 +3884,15 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect:
egui::CursorIcon::Crosshair
}
Tool::Move => egui::CursorIcon::Move,
+ // Over a path it can follow, the Type tool's path-type pointer (Photoshop).
+ Tool::Type
+ if app.drag.is_none() && {
+ let [x, y] = xf.to_doc(p);
+ crate::type_tool::path_at(app, x, y).is_some()
+ } =>
+ {
+ crate::type_tool::path_cursor(&painter, p)
+ }
// Dragging is handled with the pan itself, above.
Tool::Hand => crate::tool_cursor::hand(ui.ctx(), false),
Tool::RotateView => crate::rotate_view::cursor(response.dragged()),
diff --git a/crates/ui-egui/src/type_tool.rs b/crates/ui-egui/src/type_tool.rs
index f00fb5715..531138721 100644
--- a/crates/ui-egui/src/type_tool.rs
+++ b/crates/ui-egui/src/type_tool.rs
@@ -158,6 +158,14 @@ fn hit_offset(app: &mut PhotocraftApp, id: LayerId, x: f64, y: f64) -> usize {
pub(crate) fn offset_at(app: &mut PhotocraftApp, id: LayerId, x: f64, y: f64) -> usize {
let Some((l, aff, text)) = layout(app, id) else { return 0 };
let (tx, ty) = to_text(&aff, x, y);
+ // Type on a path: the point's place along the path is the position in the (single) line.
+ let shape = app.session.active().and_then(|s| text_layer(&s.doc, id).map(|t| t.shape.clone()));
+ let (tx, ty) = match shape {
+ Some(photocraft_doc::text::TextShape::Path { path, start, flip }) => {
+ photocraft_text::warp::arc_length_at(&path, flip, f64::from(tx), f64::from(ty)).map_or((tx, ty), |s| ((s - f64::from(start)) as f32, -1.0))
+ }
+ _ => (tx, ty),
+ };
photocraft_text::hit_char(&l, &text, tx, ty).0
}
@@ -319,6 +327,8 @@ pub fn pointer_up(app: &mut PhotocraftApp, start: [f64; 2], end: [f64; 2]) {
p["x"] = json!(start[0].round());
p["y"] = json!(start[1].round());
}
+ // A click on a shown path starts type on that path, from the point clicked (Photoshop).
+ let on_path = if p.get("box").is_none() { path_at(app, start[0], start[1]) } else { None };
let key = session_key(app);
p["coalesce"] = json!(key);
if let Ok(v) = app.run("type.create", p)
@@ -327,6 +337,14 @@ pub fn pointer_up(app: &mut PhotocraftApp, start: [f64; 2], end: [f64; 2]) {
if o.type_aa != "sharp" {
let _ = app.run("type.edit", json!({"layer": id, "antialias": o.type_aa, "coalesce": key}));
}
+ if let Some(mut q) = on_path {
+ q["layer"] = json!(id);
+ q["at"] = json!([start[0], start[1]]);
+ q["coalesce"] = json!(key);
+ if let Err(e) = app.run("type.attachToPath", q) {
+ app.ui.status = e;
+ }
+ }
// A Type Mask's text is a hidden working layer: the canvas shows the mask overlay
// instead, and committing turns it into the selection.
if mask {
@@ -338,6 +356,53 @@ pub fn pointer_up(app: &mut PhotocraftApp, start: [f64; 2], end: [f64; 2]) {
}
}
+/// The shown path a Type tool click at document point (`x`, `y`) puts type on, as
+/// `type.attachToPath` params naming it (`shape`, `subpath`): the active shape layer's path, else
+/// the work path, within a few screen pixels, as in Photoshop. Only the horizontal Type tool
+/// starts path type for now; vertical type on a path is not laid out yet.
+pub(crate) fn path_at(app: &PhotocraftApp, x: f64, y: f64) -> Option<serde_json::Value> {
+ if app.ui.tool != crate::state::Tool::Type || app.ui.text_edit.is_some() || !app.ui.view.shows(app.ui.view.show.target_path) {
+ return None;
+ }
+ let tol = f64::from(6.0 / app.point_zoom().max(0.01));
+ let hit = |p: &photocraft_doc::vector::Path| {
+ let s = match photocraft_vector::edit::hit(p, Point::new(x, y), tol, &[])? {
+ photocraft_vector::edit::Hit::Anchor([s, _]) | photocraft_vector::edit::Hit::Segment([s, _], _) => s,
+ photocraft_vector::edit::Hit::Handle(..) => return None,
+ };
+ p.subpaths.get(s).filter(|sp| sp.knots.len() >= 2).map(|_| s)
+ };
+ if let Some((id, p)) = crate::vector_ui::active_shape_path(app)
+ && let Some(s) = hit(&p)
+ {
+ return Some(json!({"shape": id, "subpath": s}));
+ }
+ let work = app.session.active()?.doc.work_path.as_ref()?;
+ hit(work).map(|s| json!({"subpath": s}))
+}
+
+/// The Type tool's pointer over a path it can follow: Photoshop's I-beam crossed by a dotted
+/// wavy line, drawn on the canvas.
+pub(crate) fn path_cursor(painter: &egui::Painter, at: Pos2) -> egui::CursorIcon {
+ let beam = |c: Color32, w: f32| {
+ let s = Stroke::new(w, c);
+ painter.line_segment([at + egui::vec2(0.0, -8.0), at + egui::vec2(0.0, 8.0)], s);
+ for dy in [-8.0, 8.0] {
+ painter.line_segment([at + egui::vec2(-3.0, dy), at + egui::vec2(3.0, dy)], s);
+ }
+ };
+ beam(Color32::WHITE, 3.0);
+ beam(Color32::BLACK, 1.0);
+ // The wave: short dashes along a sine through the beam's lower half.
+ let wave = |t: f32| at + egui::vec2(-9.0 + 18.0 * t, 5.0 - 3.0 * t + 2.0 * (t * std::f32::consts::TAU * 1.5).sin());
+ for i in (0..12).step_by(2) {
+ let (a, b) = (wave(i as f32 / 12.0), wave((i + 1) as f32 / 12.0));
+ painter.line_segment([a, b], Stroke::new(3.0, Color32::WHITE));
+ painter.line_segment([a, b], Stroke::new(1.0, Color32::BLACK));
+ }
+ egui::CursorIcon::None
+}
+
fn session_key(app: &mut PhotocraftApp) -> String {
format!("type-{}", app.ui.alloc_id())
}
@@ -998,10 +1063,24 @@ pub fn draw_overlay(app: &mut PhotocraftApp, painter: &egui::Painter, xf: &ViewX
let p = aff.apply(Point::new(x as f64, y as f64));
xf.to_screen(p.x as f32, p.y as f32)
};
+ let shape = app.session.active().and_then(|s| text_layer(&s.doc, id).map(|t| t.shape.clone()));
+ // Type on a path: the caret, selection and underline follow the curve the glyphs sit on.
+ let bend = shape.as_ref().and_then(photocraft_text::warp::Warp::on_path);
// Line space (lines, clusters, carets) → screen: vertical type turns it 90° clockwise.
let scr = |x: f32, y: f32| -> Pos2 {
let (x, y) = l.to_text(x, y);
- scr_t(x, y)
+ match &bend {
+ Some(w) => {
+ let (x, y) = w.apply(f64::from(x), f64::from(y));
+ scr_t(x as f32, y as f32)
+ }
+ None => scr_t(x, y),
+ }
+ };
+ // A line-space run from `x0` to `x1` at height `y`: sampled, so it bends with path type.
+ let run = |x0: f32, x1: f32, y: f32| -> Vec<Pos2> {
+ let n = if bend.is_some() { ((x1 - x0) / 4.0).ceil().clamp(1.0, 512.0) as usize } else { 1 };
+ (0..=n).map(|i| scr(x0 + (x1 - x0) * i as f32 / n as f32, y)).collect()
};
// Tell the OS where the caret is: this is what enables the IME and places its candidate window.
{
@@ -1017,7 +1096,6 @@ pub fn draw_overlay(app: &mut PhotocraftApp, painter: &egui::Painter, xf: &ViewX
if crate::type_transform::draw(app, painter, xf, mods) {
return;
}
- let shape = app.session.active().and_then(|s| text_layer(&s.doc, id).map(|t| t.shape.clone()));
let frame = Stroke::new(1.0, t.accent);
match shape {
Some(photocraft_doc::text::TextShape::Box { x, y, width, height }) => {
@@ -1034,7 +1112,7 @@ pub fn draw_overlay(app: &mut PhotocraftApp, painter: &egui::Painter, xf: &ViewX
for ln in &l.lines {
// Horizontal: just under the baseline; vertical: the column's centre line.
let y = if l.vertical { ln.baseline } else { ln.baseline + ln.descent * 0.25 };
- painter.line_segment([scr(ln.x0.min(0.0), y), scr(ln.x1.max(ln.x0 + 1.0), y)], Stroke::new(1.0, t.accent.gamma_multiply(0.8)));
+ painter.add(egui::Shape::line(run(ln.x0.min(0.0), ln.x1.max(ln.x0 + 1.0), y), Stroke::new(1.0, t.accent.gamma_multiply(0.8))));
}
}
}
@@ -1047,7 +1125,7 @@ pub fn draw_overlay(app: &mut PhotocraftApp, painter: &egui::Painter, xf: &ViewX
let (x0, x1) = xs.iter().fold((f32::MAX, f32::MIN), |(lo, hi), (p, q)| (lo.min(*p), hi.max(*q)));
if x0 < x1 {
let y = ln.baseline + ln.descent * 0.5;
- painter.line_segment([scr(x0, y), scr(x1, y)], Stroke::new(1.5, t.accent));
+ painter.add(egui::Shape::line(run(x0, x1, y), Stroke::new(1.5, t.accent)));
}
}
}
@@ -1064,8 +1142,15 @@ pub fn draw_overlay(app: &mut PhotocraftApp, painter: &egui::Painter, xf: &ViewX
x1 = x1.max(ln.x1 + (ln.ascent + ln.descent) * 0.25);
x0 = x0.min(ln.x1);
}
- if x0 < x1 {
- let (top, bot) = (ln.baseline - ln.ascent, ln.baseline + ln.descent);
+ let (top, bot) = (ln.baseline - ln.ascent, ln.baseline + ln.descent);
+ if bend.is_some() {
+ // On a path each glyph turns on its own, so each gets its own highlight.
+ // Glyphs past the end of the path are not drawn, so neither is their highlight.
+ let shown = |p: f32, q: f32| bend.as_ref().is_some_and(|w| w.place_glyph(f64::from(p + q) / 2.0) != photocraft_text::warp::Placement::Hidden);
+ for (p, q) in xs.into_iter().filter(|&(p, q)| shown(p, q)) {
+ painter.add(egui::Shape::convex_polygon(vec![scr(p, top), scr(q, top), scr(q, bot), scr(p, bot)], fill, Stroke::NONE));
+ }
+ } else if x0 < x1 {
painter.add(egui::Shape::convex_polygon(vec![scr(x0, top), scr(x1, top), scr(x1, bot), scr(x0, bot)], fill, Stroke::NONE));
}
}
@@ -2541,6 +2626,62 @@ mod tests {
assert!(app.ui.text_edit.is_none());
}
+ /// TYPE-218-1: a Type tool click on the work path starts type on the path from the point
+ /// clicked, in one history step with the placeholder selected; a click off it is point text.
+ #[test]
+ fn click_on_a_path_starts_type_on_the_path() {
+ use photocraft_doc::text::TextShape;
+ let mut app = app();
+ app.session
+ .edit("path", |doc, _| {
+ doc.work_path = Some(photocraft_doc::vector::Path::new(vec![photocraft_doc::vector::Subpath::polyline(&[(20.0, 100.0), (380.0, 100.0)])]));
+ Ok(())
+ })
+ .unwrap();
+ assert!(path_at(&app, 200.0, 101.0).is_some());
+ assert!(path_at(&app, 200.0, 160.0).is_none(), "off the path");
+ let before = app.session.active().unwrap().history.entries().len();
+ assert!(!pointer_down(&mut app, 200.0, 101.0, egui::Modifiers::NONE));
+ pointer_up(&mut app, [200.0, 101.0], [200.0, 101.0]);
+ let ed = app.ui.text_edit.clone().unwrap();
+ assert_eq!((ed.anchor, ed.caret), (0, PLACEHOLDER.chars().count()), "the placeholder is selected");
+ let shape = text_layer(&app.session.active().unwrap().doc, LayerId(ed.layer)).unwrap().shape.clone();
+ assert!(matches!(shape, TextShape::Path { start, flip: false, .. } if (start - 180.0).abs() < 0.5), "{shape:?}");
+ assert_eq!(app.session.active().unwrap().history.entries().len(), before + 1, "one step for the click");
+ insert(&mut app, "On the line");
+ assert_eq!(layer_text(&app), "On the line");
+ commit(&mut app);
+ // With the vertical tool a click does not start path type.
+ app.ui.tool = crate::state::Tool::VerticalType;
+ assert!(path_at(&app, 200.0, 101.0).is_none());
+ app.ui.tool = crate::state::Tool::Type;
+ pointer_up(&mut app, [200.0, 160.0], [200.0, 160.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 click in type on a path puts the caret at the glyph there along the curve, not where the
+ /// straight line would have it.
+ #[test]
+ fn caret_hits_type_on_a_path_along_the_curve() {
+ let mut app = app();
+ app.session
+ .edit("path", |doc, _| {
+ doc.work_path = Some(photocraft_doc::vector::Path::new(vec![photocraft_doc::vector::Subpath::polyline(&[(300.0, 10.0), (300.0, 195.0)])]));
+ Ok(())
+ })
+ .unwrap();
+ pointer_up(&mut app, [300.0, 20.0], [300.0, 20.0]);
+ insert(&mut app, "ABCDEFGH");
+ let id = LayerId(app.ui.text_edit.as_ref().unwrap().layer);
+ assert!(matches!(text_layer(&app.session.active().unwrap().doc, id).unwrap().shape, photocraft_doc::text::TextShape::Path { .. }));
+ // The type runs down the path: near its start the caret is at the beginning, far down at the end.
+ assert_eq!(offset_at(&mut app, id, 300.0, 18.0), 0);
+ // (The straight line would put both of these at the start: they are left of its first glyph.)
+ let (mid, far) = (offset_at(&mut app, id, 296.0, 60.0), offset_at(&mut app, id, 296.0, 190.0));
+ assert!(0 < mid && mid < far, "{mid} {far}");
+ }
+
/// Preferences ▸ Units & Rulers ▸ Type switches the display unit of type metrics: points by
/// default, pixels by the document's resolution, or millimetres.
#[test]
diff --git a/crates/ui-egui/src/vector_ui.rs b/crates/ui-egui/src/vector_ui.rs
index e9d998b04..3b4f21895 100644
--- a/crates/ui-egui/src/vector_ui.rs
+++ b/crates/ui-egui/src/vector_ui.rs
@@ -931,7 +931,8 @@ pub(crate) fn draw_handle(painter: &egui::Painter, anchor: Pos2, handle: Pos2, a
/// Work path / active shape path outlines, anchors, and the pen path in progress.
pub fn draw_overlay(app: &PhotocraftApp, painter: &egui::Painter, xf: &ViewXform, doc: &Document) {
let tool = app.ui.tool;
- let vector_tool = matches!(tool, Tool::Pen | Tool::FreeformPen | Tool::CurvaturePen | Tool::PathSelection) || is_shape_tool(tool);
+ // The Type tool shows the paths too: a click on one starts type on it (Photoshop).
+ let vector_tool = matches!(tool, Tool::Pen | Tool::FreeformPen | Tool::CurvaturePen | Tool::PathSelection | Tool::Type) || is_shape_tool(tool);
let accent = Tokens::get(painter.ctx()).accent;
let to_scr = |q: [f64; 2]| xf.to_screen(q[0] as f32, q[1] as f32);
let draw_path = |p: &Path, anchors: bool| {
diff --git a/docs/gaps.md b/docs/gaps.md
index 25a286aab..4aaba8506 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-10-13 · **Change:** minor (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) · **Target:** Adobe Photoshop 2026
+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (G8: a Type tool click on a path starts path type, TYPE-218-1 partial; 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) · **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
@@ -78,7 +78,9 @@ 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
+- **Missing:** the rest of type on a path (TYPE-218-1: glyphs along the curve, `type.attachToPath` and
+ the Type tool's click on a shown path landed; the caret on the curve, dragging the start, vertical
+ path type and PSD path text remain), 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
@@ -263,6 +265,7 @@ what an agent can't finish alone.
| Date | Change | Summary |
|---|---|---|
+| 2026-10-13 | minor | G8: a Type tool click on the work path or the active shape layer's path starts type on it at the point clicked (TYPE-218-1, partial); no readiness percentage or estimate changed |
| 2026-10-13 | minor | G4: Hue Jitter amount-track appearance (#3825, partial); no readiness percentage or estimate changed |
| 2026-10-13 | minor | G4: minimum inputs in Shape Dynamics and Transfer follow their Control (#3825, partial); no readiness percentage or estimate changed |
| 2026-10-12 | minor | G5: Free Transform options bar H/V skew fields done |
diff --git a/docs/scorecard.md b/docs/scorecard.md
index 92f9315eb..b9a02ae95 100644
--- a/docs/scorecard.md
+++ b/docs/scorecard.md
@@ -210,7 +210,7 @@ Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_w
| Id | Target | Status | Issue | Note |
|---|---|---|---|---|
-| TYPE-218-1 | Type on a path: path shape, glyphs along the curve, caret follows, PSD round trip | partial | [#218](https://github.com/storytold/photocraft/issues/218) | TextShape::Path (doc text.rs) with glyphs placed rigidly along the curve by arc length (text warp.rs PathFrame), type.attachToPath and type.detachFromPath (#4365), .pcraft round trip. Missing: clicking a path with the Type tool, the caret and selection following the curve, and PSD path text (it saves as point text) |
+| TYPE-218-1 | Type on a path: path shape, glyphs along the curve, caret follows, PSD round trip | partial | [#218](https://github.com/storytold/photocraft/issues/218) | TextShape::Path (doc text.rs) with glyphs placed rigidly along the curve by arc length (text warp.rs PathFrame), type.attachToPath and type.detachFromPath (#4365), .pcraft round trip; a Type tool click on the work path or the active shape layer's path starts path type at the point clicked (type.attachToPath at, path-type pointer over a path). Missing: vertical type on a path, dragging the start/flip, the caret and selection following the curve, and PSD path text (it saves as point text) |
| TYPE-218-2 | Paragraph direction (Auto/LTR/RTL) in the panel and options bar; visual RTL caret | missing | [#218](https://github.com/storytold/photocraft/issues/218) | Engine has TextDirection (text.rs:155); no UI |
| TYPE-218-3 | Thai/Khmer/Indic fallback fonts; golden shaping tests for complex scripts and RTL | partial | [#218](https://github.com/storytold/photocraft/issues/218) | Fallback fonts are covered for Thai, Khmer, Lao, Myanmar (THAI_FAMILIES, KHMER_FAMILIES, LAO_FAMILIES, MYANMAR_FAMILIES in fonts.rs; #1909, #3259), the nine Indic scripts (INDIC_FAMILIES: Nirmala UI, Kohinoor and Sangam MN, Noto Sans) and Arabic and Hebrew. Still missing: per-script golden shaping tests against reference output (only smoke tests that an installed font shapes without .notdef, plus a bidi test) |
| 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 |
diff --git a/scorecard/type.toml b/scorecard/type.toml
index ee8a876a4..dc15b5bb3 100644
--- a/scorecard/type.toml
+++ b/scorecard/type.toml
@@ -9,7 +9,7 @@ id = "TYPE-218-1"
target = "Type on a path: path shape, glyphs along the curve, caret follows, PSD round trip"
status = "partial"
issue = 218
-note = "TextShape::Path (doc text.rs) with glyphs placed rigidly along the curve by arc length (text warp.rs PathFrame), type.attachToPath and type.detachFromPath (#4365), .pcraft round trip. Missing: clicking a path with the Type tool, the caret and selection following the curve, and PSD path text (it saves as point text)"
+note = "TextShape::Path (doc text.rs) with glyphs placed rigidly along the curve by arc length (text warp.rs PathFrame), type.attachToPath and type.detachFromPath (#4365), .pcraft round trip; a Type tool click on the work path or the active shape layer's path starts path type at the point clicked (type.attachToPath at, path-type pointer over a path). Missing: vertical type on a path, dragging the start/flip, the caret and selection following the curve, and PSD path text (it saves as point text)"
[[item]]
id = "TYPE-218-2"