diff --git a/crates/engine/src/cmd/dimension.rs b/crates/engine/src/cmd/dimension.rs index 62b268d50..ec1f91f20 100644 --- a/crates/engine/src/cmd/dimension.rs +++ b/crates/engine/src/cmd/dimension.rs @@ -254,7 +254,13 @@ pub(crate) fn conform(doc: &mut Document) { doc.walk(|n| { if let Some(d) = &n.extras().dimension { let mut off = false; - n.walk(&mut |c| off |= [c.appearance.fill_paint(), c.appearance.stroke_paint()].iter().filter_map(|p| p.color()).any(|c| off_mode(&c))); + n.walk(&mut |c| { + off |= [c.appearance.fill_paint(), c.appearance.stroke_paint()].iter().filter_map(|p| p.color()).any(|c| off_mode(&c)); + // The label's characters carry their own fill. + if let NodeKind::Text(t) = &c.kind { + off |= t.runs.iter().filter_map(|r| r.style.fill.color()).any(|c| off_mode(&c)); + } + }); if off { stale.push((n.id, (**d).clone())); } diff --git a/crates/engine/tests/dimensions.rs b/crates/engine/tests/dimensions.rs index 2c99eec0b..8413aef71 100644 --- a/crates/engine/tests/dimensions.rs +++ b/crates/engine/tests/dimensions.rs @@ -520,4 +520,26 @@ fn dimension_colours_follow_the_document_colour_model() { s.add_document(old, None); let opened = colours(&s, id); assert!(!opened.is_empty() && opened.iter().all(|c| *c == k), "{opened:?}"); + // Only the label's characters in RGB (their fill is saved apart from the node's): redrawn too. + let mut old = (*s.doc().unwrap().doc).clone(); + let label = { + let mut found = None; + old.node(NodeId(id)).unwrap().walk(&mut |n| { + if matches!(n.kind, vectorcraft_doc::NodeKind::Text(_)) { + found = Some(n.id); + } + }); + found.expect("a dimension label") + }; + if let Some(vectorcraft_doc::NodeKind::Text(t)) = old.node_mut(label).map(|n| &mut n.kind) { + for r in &mut t.runs { + r.style.fill = vectorcraft_color::Paint::solid(vectorcraft_color::Color::rgb8(0, 0, 0)); + } + } + s.add_document(old, None); + let runs = |s: &Session| match &s.doc().unwrap().doc.node(label).unwrap().kind { + vectorcraft_doc::NodeKind::Text(t) => t.runs.iter().filter_map(|r| r.style.fill.color()).collect::>(), + _ => Vec::new(), + }; + assert!(!runs(&s).is_empty() && runs(&s).iter().all(|c| *c == k), "{:?}", runs(&s)); }