.ai import: the page check weighs a live envelope of type as the art it draws

The comparison with the page counts the area of each text object that
shows as type, which it holds to less (type laid out again from the
file's text can sit a little apart from the page's). It took the text
object in a live envelope's contents for such type, at its own unbent
box, so most of what an envelope of type draws went unweighed: one
opened live where the page draws other art there, with only a note
that the type differs. The envelope draws its type bent, as art, and
is now weighed as such, as the drawn art it takes the place of is.

Part of #3179.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jmverges
2026-11-10 17:26:19 +00:00
co-authored by Claude Opus 5.5
parent 47b20b4366
commit 0916b40654
2 changed files with 23 additions and 2 deletions
+5 -2
View File
@@ -714,7 +714,8 @@ fn compared_with_solid(x: &vectorcraft_render::Rendered, y: &vectorcraft_render:
}
/// Where the type that shows in `nodes` is, in pixels of `region` drawn at `scale` (with a margin
/// for the strokes round it).
/// for the strokes round it). The type in a live envelope isn't: the envelope draws it bent, away
/// from its text object's box, and is weighed as the art it draws, as its drawn art would be.
fn type_areas(nodes: &[Arc<Node>], region: Rect, scale: f64, out: &mut Vec<Rect>) {
for n in nodes.iter().filter(|n| n.visible) {
if let NodeKind::Text(_) = n.kind
@@ -723,7 +724,9 @@ fn type_areas(nodes: &[Arc<Node>], region: Rect, scale: f64, out: &mut Vec<Rect>
let px =
|r: Rect| Rect::new((r.x0 - region.x0) * scale, (r.y0 - region.y0) * scale, (r.x1 - region.x0) * scale, (r.y1 - region.y0) * scale);
out.push(px(b.inflate(OUTLINE_REACH, OUTLINE_REACH)));
} else if let Some(c) = n.children() {
} else if !matches!(n.kind, NodeKind::Envelope { .. })
&& let Some(c) = n.children()
{
type_areas(c, region, scale, out);
}
}
+18
View File
@@ -5473,6 +5473,24 @@ fn an_envelope_of_type_waits_on_the_page_of_layers_that_would_open_alone() {
assert_eq!(loose, [("Note".to_string(), true)], "{notes:?}");
}
/// An envelope of type that draws as its drawn art doesn't open live where the page draws other art
/// there (the warp bent the other way): the page check weighs the live envelope as the art it draws,
/// not as type laid out again, so it sees the two differ. The file comes in as its page, as it does
/// with the drawn art (#3179).
#[test]
fn an_envelope_of_type_that_draws_apart_from_the_page_does_not_open_live() {
let Some(family) = installed_family() else { return };
let doc = type_envelope_text(&family, None);
let text = made_envelope_type(&doc);
let (drawn, _) = drawn_envelope(&arc_envelope(&text, 30.0));
let (_, page) = drawn_envelope(&arc_envelope(&text, -30.0));
let art = native_with_text(&layer("Art", true, &format!("{}\n{}", square(10, 10), type_envelope(&arc_keys(0.3), &drawn))), &doc);
let r = import(&eps(&format!("{}\n{page}", page_square(10, 10)), &art)).unwrap();
let (envelopes, _) = envelopes_and_type(&r.document);
assert!(envelopes.is_empty(), "{envelopes:?} {:?}", r.warnings);
assert!(r.warnings.iter().any(|n| n.contains("layers weren't read") && n.contains("differs from the page's")), "{:?}", r.warnings);
}
/// The fill of the first run of type `n`.
fn text_fill(n: &Node) -> Option<vectorcraft_color::Color> {
let NodeKind::Text(t) = &n.kind else { return None };