From 6643d5cf2ad40337fc5e70b8f553071230d4bf89 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 11:02:01 -0800 Subject: [PATCH] PDF/.ai import: legacy TG, Xu and Tu with bad operands give no warning A line breaking value (TG) or Japanese layout rules (Xu, Tu) with missing or non-numeric operands no longer mark the setting as set, so the next visible text object gives no warning about a setting the file did not specify. --- crates/eps/src/import/ai/legacy_text.rs | 7 ++++--- crates/eps/src/import/ai/tests.rs | 10 ++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/eps/src/import/ai/legacy_text.rs b/crates/eps/src/import/ai/legacy_text.rs index 61ac106e1a..a3864b43d0 100644 --- a/crates/eps/src/import/ai/legacy_text.rs +++ b/crates/eps/src/import/ai/legacy_text.rs @@ -751,9 +751,10 @@ impl Reader<'_> { _ => {} } } - // `linebreak TG` and `prop cjkLayout cjkRoman cjkCjk Xu` (`Tu` the same, §22.6). - "TG" => st.line_breaking = true, - "Xu" | "Tu" => st.japanese_layout = true, + // `linebreak TG` and `prop cjkLayout cjkRoman cjkCjk Xu` (`Tu` the same, §22.6). Either + // one is set only when its operands are numbers. + "TG" => st.line_breaking |= n0.is_some(), + "Xu" | "Tu" => st.japanese_layout |= nums::<4>(vals).is_some(), _ => {} } } diff --git a/crates/eps/src/import/ai/tests.rs b/crates/eps/src/import/ai/tests.rs index b3a01fddc1..a0ade95c5e 100644 --- a/crates/eps/src/import/ai/tests.rs +++ b/crates/eps/src/import/ai/tests.rs @@ -4387,6 +4387,16 @@ fn legacy_line_breaking_and_japanese_layout_rules_are_warned_once() { assert_eq!(art_texts(&r.doc)[0].plain_text(), "Hi"); } +/// `TG`, `Xu` and `Tu` with missing or non-numeric operands set nothing, so they give no warning. +#[test] +fn legacy_line_breaking_and_japanese_layout_rules_with_bad_operands_are_not_warned() { + for attrs in ["TG", "(a) TG", "1 120 150 Xu", "0 1 (a) 150 Xu", "Tu", "0 1 120 (a) Tu"] { + let r = legacy_read(&point_type(attrs, "a")); + assert!(r.warnings.is_empty(), "{attrs}: {:?}", r.warnings); + assert_eq!(art_texts(&r.doc)[0].plain_text(), "a", "{attrs}"); + } +} + /// Spacing is kept to the ranges the Justification options take, a Minimum, Desired and Maximum /// out of order go back to their defaults, and hyphenation's letter counts and limit to the ranges /// `text.setFormat` takes.