.ai import: legacy type used as a mask clips its clipping group

In the legacy format, `Tr` sets the rendering mode of the type that
follows. Section 5.7 of the version 7 specification says that modes 4 to
7 make the text object a mask: 4, 5 and 6 also fill, stroke, or fill and
stroke it, and 7 paints nothing. Sections 15.3.2 and 15.4.5.1 add that
these modes are used in pattern definitions, and the reader does not
read type in a pattern. The reader painted 4 to 6 like 0 to 2 and never
clipped, so the art a text mask clips showed whole.

A text object with characters in modes 4 to 7 is now a clipping path of
its clipping group (`q` ... `Q`, or the layer), as a path painted with
`W` is, and the whole object is the mask. Beside other clipping paths it
nests as they do, and the mode lasts into later text objects. Area type
with linked areas (threaded frames, also when the reader's limits keep
one frame), and type in wraparound text or in a compound path, a group
inside them included, doesn't clip, with a warning.

A `Tr` operand that is not a whole number from 0 to 9 now leaves the
mode as it was; before, 4.5 read as 4 and -4 hid the type.

The new warning and the reader's warning about linked type areas left
out get rows in every catalog.
This commit is contained in:
dotCooCoo
2026-11-05 21:18:44 +07:00
committed by bflatastic
parent cbb09c70d2
commit 6e2a32c2a0
30 changed files with 272 additions and 4 deletions
+6 -1
View File
@@ -3312,7 +3312,7 @@ proptest! {
#[test]
fn ai_line_widths_never_panic(
width in prop::sample::select(vec!["0", "0.0", "-0", "-1", "1e308", "1e-308", "nan", "inf", "2"]),
render in prop::sample::select(vec!["0", "1", "2", "5", "6", "7", "-1", "99"]),
render in prop::sample::select(vec!["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "4.5", "-1", "99"]),
cut in 0usize..2_000,
edits in prop::collection::vec((0usize..2_000, prop::sample::select(vec!['0', '1', '-', '.', ' ', '\n', '(', ')', 'w', 'B', 'S', 'T'])), 0..8),
) {
@@ -4087,6 +4087,11 @@ fn arb_ai_token() -> impl Strategy<Value = String> {
"0 0 1e308 -1e308 Te",
"TM",
"7 Tr",
"4 Tr",
"9 Tr",
"4.5 Tr",
"*w",
"*W",
"-1e308 Ts",
"1e308 0 Tz",
"1e308 Tt",