Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

EPS import: joined text lays out its bounds afresh

Matthew Farrow94dfa20fa0be
diff --git a/crates/eps/src/import/native.rs b/crates/eps/src/import/native.rs
index 100fede02..e6b8edeca 100644
--- a/crates/eps/src/import/native.rs
+++ b/crates/eps/src/import/native.rs
@@ -798,6 +798,9 @@ fn join_pieces(parts: &mut Vec<Arc<Node>>, lines: &[(String, Point)]) {
&& let NodeKind::Text(t) = &mut node.kind
{
t.runs = runs.into_iter().flatten().collect();
+ // The layout cached for the first piece is not this text's.
+ t.cached_bounds = None;
+ t.cached_baselines.clear();
}
let mut gone: Vec<usize> = rest.clone();
gone.sort_unstable_by(|a, b| b.cmp(a));
diff --git a/crates/eps/src/import/tests_native.rs b/crates/eps/src/import/tests_native.rs
index 6fddba75c..93a00a5a0 100644
--- a/crates/eps/src/import/tests_native.rs
+++ b/crates/eps/src/import/tests_native.rs
@@ -423,6 +423,9 @@ fn a_line_the_page_draws_in_pieces_goes_to_its_text_object_whole() {
let texts: Vec<String> =
group.children().unwrap().iter().filter_map(|n| if let NodeKind::Text(t) = &n.kind { Some(t.plain_text()) } else { None }).collect();
assert_eq!(texts, ["Hi there"]);
+ // Its bounds are laid out afresh for the whole text, not those of the first piece.
+ let NodeKind::Text(t) = &group.children().unwrap()[0].kind else { panic!("text") };
+ assert!(t.cached_bounds.is_none() && t.cached_baselines.is_empty());
}
#[test]