mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-10 13:01:29 +00:00
A /DA string comes from the file. Reviewing how the PR reads it:
- An operand that is not a finite number was taken as one: Rust parses
"NaN" and "inf", so "NaN NaN NaN rg" reached the appearance stream as
"NaN NaN NaN rg" (clamping keeps NaN), and "/Helv inf Tf" drew at the
400 pt cap. parse_da now ignores such an operand with its operator.
- A Tf without its size ("/TiRo Tf") lost its font: da_font_name read
the name two tokens before Tf only. The name is now read whether or
not a size sits between it and Tf; the size falls back to 12 pt.
- A zero or negative size keeps the default 12 pt (zero is auto-size
only for form fields, §12.7.4.3; a text box has none), now stated in
parse_da's comment.
Tests (each fails with its fix reverted): a text_style unit test over
missing, zero, negative, NaN, infinite, huge and non-numeric sizes,
missing Tf, non-finite and out-of-range colours, garbage and non-UTF-8
bytes; and an appearance test that draws boxes from such /DA strings,
including a font in /DR and one no /DR lists, and checks the stream's
font, size and colour and that no NaN or inf reaches it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv