Color Effects: screen print marks check type lines without the target weight

The canvas-edge check padded every mark by the target stroke weight, so a
line of type that fit inside the canvas could be refused. Only the stroked
targets are padded now; each line of type is checked by its layout box and
its glyphs' ink, underline and strikethrough bars included.
This commit is contained in:
dotCooCoo committed 2026-12-01 07:14:51 -08:00
1 parent 43cccb74cf
commit 31f755960f
2 files changed
+20 -3

No files matched your search

@@ -321,9 +321,16 @@ fn screen_marks(s: &mut Session, p: &Value) -> Result<Value> {
let st = s.doc()?;
let layer = marks_layer(&st.doc).map(|l| (l.id, l.children().cloned().unwrap_or_default()));
let drawn: Vec<Node> = boards.iter().map(|(r, board)| marks.group(*r, *board, &mut || NodeId(0))).collect();
let reach = marks.weight;
let beyond = |b: Rect| [b.x0 - reach, b.y0 - reach, b.x1 + reach, b.y1 + reach].iter().any(|v| !v.is_finite() || v.abs() > MAX_COORD);
if drawn.iter().any(|g| g.geometric_bounds().is_some_and(beyond)) {
// Only the stroked targets reach past their paths by the target weight. The lines of type have
// no stroke; their glyphs' ink, underline and strikethrough bars included, is checked as well.
let past = |b: Rect, reach: f64| [b.x0 - reach, b.y0 - reach, b.x1 + reach, b.y1 + reach].iter().any(|v| !v.is_finite() || v.abs() > MAX_COORD);
let beyond = |n: &Node| match &n.kind {
NodeKind::Text(t) => {
n.geometric_bounds().is_some_and(|b| past(b, 0.0)) || t.ink().flatten().is_some_and(|ink| past(t.xf.transform_rect_bbox(ink), 0.0))
}
_ => n.geometric_bounds().is_some_and(|b| past(b, marks.weight)),
};
if drawn.iter().any(|g| g.children().is_some_and(|kids| kids.iter().any(|k| beyond(k)))) {
return Err(bad(C, format!("the marks would reach past the edge of the canvas (±{MAX_COORD} pt)")));
}
if let Some((layer, kids)) = &layer {
@@ -181,6 +181,16 @@ fn marks_past_the_canvas_edge_are_refused() {
run(&mut s, json!({"artboard": 1, "positions": ["right"]}));
}
#[test]
fn the_target_weight_does_not_pad_lines_of_type_at_the_canvas_edge() {
let mut s = session();
// The artboard ends 10 pt inside the canvas edge.
s.execute("artboard.new", &json!({"x": 3999090, "y": 0, "width": 900, "height": 100})).unwrap();
let p = json!({"artboard": 1, "positions": [], "info": true, "textAlign": "right", "inset": 0, "weight": 20});
let r = run(&mut s, p);
assert_eq!(lines(&node(&s, r["ids"][0].as_u64().unwrap())).len(), 1);
}
#[test]
fn every_artboard_gets_its_group_and_one_artboard_rerun_keeps_the_others() {
let mut s = session();