From 495694e1ac29599da359810e3df820b94ebdf039 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sat, 10 Oct 2026 07:32:08 +0700 Subject: [PATCH] Part of #758: .ai import doesn't weigh text objects when the layers can't be used Before deciding to use the layers of an Illustrator file, the import drew them again for each text object made from the file's text document, to see whether the page draws it. When the layers differ from the page by more than the check allows even with every such object gone (taking one out only changes what is drawn in its box), the layers aren't used whatever is taken out: that weighing is now skipped. Co-Authored-By: Claude Opus 5.5 --- crates/eps/src/import/native.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/eps/src/import/native.rs b/crates/eps/src/import/native.rs index e7a6c78c..d0aff0c0 100644 --- a/crates/eps/src/import/native.rs +++ b/crates/eps/src/import/native.rs @@ -936,6 +936,14 @@ fn prune_unseen(frame: &Frame<'_>, view: &mut PageView, doc: &mut Document) -> u return 0; } let mut with = view.difference(doc, rect).any; + // Taking a text object out changes only what is drawn in its box. When the art would still + // differ from the page by more than `compare` allows with every candidate gone, the layers + // aren't used whatever is pruned: don't draw them again for each one (#758). + let margin = OUTLINE_REACH + 1.0; + let boxes: f64 = found.iter().filter_map(|(_, b)| *b).map(|b| b.inflate(margin, margin).intersect(rect).area().max(0.0)).sum(); + if with - boxes / rect.area().max(1e-9) > MAX_DIFFERENCE { + return 0; + } let mut removed = 0; for (id, bounds) in found { if bounds.is_none_or(|b| b.intersect(rect).is_zero_area()) {