Conflicts in docs only (status lines, changelog rows and table rows):
main's entries and this branch's are both kept, each once.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Answers the fourth CodeRabbit review on #8549.
When a fill pass finishes lines beyond MAX_PARKED, their unstroked
glyphs are recorded (bounded at 4096). The first stroke after that
which could have gone over one of them ends the stroke pass, so a TJ
over more than 65 lines that comes back to where it began stays a
filled object and a stroked one for each part, as documented. Any
other first stroke drops the record, so type after an overflowing TJ,
filled only or not, is matched as before.
MAX_HELD's doc now says that one operator filling the same run of more
than 4096 glyphs twice at the same places is matched as well as it can
be: the reader tells no operator's start.
Answers the third CodeRabbit review on #8549.
- stroke_last no longer restyles the glyph drawn last once a boundary
(end_fills) closed it: a stroke after an ActualText span no longer
strokes its replacement text. A glyph stroked again where it was just
drawn still stays one object.
- Past MAX_HELD, the held strokes go over the last run of consecutive
fills they match with room for all of them, not the first, so a long
stroke pass no longer takes the same glyphs an earlier operator
filled at the same place.
- Docs: the limit is 64 kept-back lines plus the open one, so a TJ over
up to 65 lines stays filled and stroked.
Answers the second CodeRabbit review on #8549.
- A stroke that goes over no filled glyph (stroked type of its own) and
the start and end of an ActualText span now end the stroke pass
(Builder::end_fills): the held strokes are matched, the parked lines
finished and the open line's fills closed, so a later stroke can't go
over an earlier fill and a later span keeps its own replacement text.
- ActualText fills are ordinary entries in the line's fill list, and
span strokes are held and matched in replay order like any other, so
an A/B/A TJ in a span strokes the replacement. The actual_fills map,
stroke_parked and has_actual_fill are gone.
- Past MAX_HELD, the held strokes are matched to the first run of
glyphs filled one right after another that they go over
(Builder::replayed), with bounded work, instead of each to its first
match, which could reach an earlier operator's fill.
- Docs state that past 64 lines in one operator each part stays a
filled object and a stroked one.
Conflicts in docs only (the status lines, the changelog rows, the M4 Files
row, the File formats rows and the evidence list): main's entries and this
branch's are both kept, each once.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A TJ can draw the same glyph at the same place twice (its kerning goes
back), so a stroke can't be matched to a filled glyph as it arrives:
[(A) -3500 (B) 4834 (A)] TJ put the first A's stroke on the last A and
left the earlier parts unstroked. Strokes over filled glyphs are now
held until their stroke pass ends and then matched to the glyphs filled
last, in the order they were filled, so each copy is stroked where it
was filled, while a glyph filled and stroked where one filled before
stands still strokes only the newest. At most 4096 strokes are held.
Docs: ordinary text gives one filled and stroked object per part; in an
ActualText span it stays one replacement object on the first glyph's
line and style.
The reader fills every glyph of a text-showing operator, then strokes
them. When a TJ's kerning started a new line part way through, the
first line was finished before the stroke pass came back to it, so its
strokes found no filled glyph and came in as stroke-only type over
fill-only type.
A line a glyph doesn't fit is now parked while a stroke may still be
drawn over it, and a stroke-only glyph is matched against the open line
and then the parked lines, newest first. Parked lines are finished
oldest first before the open line, so drawing order is kept, and at
most 64 are parked.
The writer passed no language to craft-pdf, so exported and printed
PDFs had no /Lang and accessibility checkers failed primary-language.
Writer::new now passes the BCP 47 tag of the Document Setup language
(new vectorcraft_doc::setup::language_tag, en-US by default) through
write::Writer::new_with_language, which writes the catalog's /Lang and
the XMP dc:language. A language with no tag writes none. /MarkInfo is
left for tagged PDF (#3643).
Conflicts in docs only (the status lines, the changelog rows, the M4 Files
row, the File formats rows and the evidence list): main's entries and this
branch's are both kept, each once.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Patch::apply wrote each cross-reference entry by walking every edit, so a
pass with many edits took time in proportion to objects times edits. It
now keeps the running total of the length changes and finds, by binary
search over the edits' ends, how far each object moved. For every edit
set that apply still accepts, the written file is byte for byte the same.
An offset that no longer fits the ten digits of a cross-reference entry
(ISO 32000-1, 7.5.4) is now refused with an error instead of writing an
eleven-digit entry that breaks the table. A change in length too large
for an isize is refused with an error instead of wrapping.
Conflicts in docs only (the status lines, the changelog rows, the M4 Files
row, the File formats rows and the evidence list): main's entries and this
branch's are both kept, each once.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A PostScript plate has no blending modes, so an overprinting gradient
whose stops mix zero and nonzero ink of a plate was drawn whole on it,
and its paper-white part knocked out the ink below.
On a plate, the EPS writer now clips an overprinting gradient to where
it puts the plate's ink down. Linear, radial and diamond gradients leave
out the stretches between paper-white stops and the padding past a
paper-white end stop. Conic gradients leave out their paper-white
wedges, and freeform gradients leave out their paper-white cells (masked
at Level 3, clipped at Level 2). Fills, strokes (within, along and
across) and characters are covered, on process and spot plates. Where
the gradient puts ink down it is drawn as before, and a gradient with
ink everywhere is written unchanged.
On PostScript plates, a stop or point of an overprinting gradient whose
color counts as black, with up to half a percent of another ink, now
puts none of that other ink down, as a solid fill of that color already
does. PDF plates are unchanged.
A file whose catalog has a CMYK /GTS_PDFX output intent describes its
DeviceCMYK colors with that intent's profile. A DeviceCMYK image in
such a file now opens tagged with that profile, so a CMYK image that a
PDF/X export writes as DeviceCMYK opens with its profile again.
An image drawn where a /DefaultCMYK is in scope keeps no profile, since
the default replaces DeviceCMYK there. The scope is read per image from
the resources it is drawn with, and the image cache keeps the tagged and
untagged reads apart.
The scan that looks for d0 glyph procedures ran every time a page or a
form listed a Type 3 font in a font dictionary of its own, and its result
was dropped once the font had been noted. It now runs when the font is
first noted for the document. Each page still maps the font's glyphs,
and the note the import keeps for the font is unchanged.
On PostScript separations, up to half a percent of another ink in a color
that counts as 100% black is left off that ink's plate, so an overprinting
near black does not knock out the ink below it. A color linked to a swatch
the document does not have was left out of that rule, although it separates
from its own values like an unlinked color and Overprint Black marks it to
overprint. A 100% K with 0.4% cyan linked to such a name then stayed on the
cyan plate and knocked out the cyan under it.
A link to a missing swatch now counts as unlinked for this rule, on solid
fills, strokes, character fills and gradient stops. Spot swatches and
Registration are still excluded, and PDF plates still draw the faint ink.
Conflicts in docs only (the status lines, the changelog rows, the M4 Files
row and the File formats rows): main's entries and this branch's are both
kept, each once.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A PDF/X-3 or PDF/X-4 export tagged every CMYK color with an ICC-based
space of the same profile that the output intent embeds. In PDF/X-3 and PDF/X-4, CMYK colors in the
profile of a CMYK output intent are now DeviceCMYK, and the profile is
written once, as the output intent's DestOutputProfile (ISO 32000-1,
14.11.5:
https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf#page=641).
- With output.profiles none and a CMYK output intent, PDF/X-3 and PDF/X-4
write every CMYK color as DeviceCMYK, unless colors are converted to a
CMYK destination of another profile, which keeps its tag. Before, those
standards tagged every color whatever profiles said.
- RGB and gray colors stay tagged, and so do CMYK colors and images in
another profile.
- A CMYK image that carries the output intent's profile is DeviceCMYK,
and so is every CMYK image when none makes CMYK colors DeviceCMYK. A
CMYK JPEG then loses its ICC_PROFILE segments.
- Transparency groups blend in DeviceCMYK when CMYK colors are
DeviceCMYK, also when the file has no ICC-based CMYK space.
- Files without a standard keep the tags that profiles asks for.
- The Save PDF dialog's note for PDF/X-3 and PDF/X-4 says that CMYK
colors in the output intent's profile are written as DeviceCMYK.
Docs: docs/mcp.md, docs/target-app-parity.md and the document.exportPdf
params text.
Look::takes let a glyph filled only join a run whose glyphs were also
stroked, so after mode 2 text a mode 0 glyph took the run's stroke:
`2 Tr (B) Tj 0 Tr (C) Tj` came in as "BC" stroked throughout. A glyph
now joins only a run drawn alike (fill, stroke, overprints), so a glyph
filled only starts a run of its own and takes a stroke only when the
matched-stroke path (#8039) strokes it.
flush_stroke no longer strokes a whole run in place: a whole run goes
through the split and join code, so fill and stroke rendering glyph by
glyph still builds one stroked run.
In the pinned CMap, each lookup of a code in a `bfrange` copies the
range's whole destination and decodes it, so a `ToUnicode` map under the
256 KB limit with one long destination, shared by many fonts whose `W`
names every CID, cost millions of long copies. `MAX_CHARS` didn't stop
it, since such lookups give no character.
- A `ToUnicode` map holding a string longer than 128 bytes decoded
(`MAX_DESTINATION`: hex, literal, or any ASCII85 string, whose `z`
stands for four bytes), or written as a binary CMap, is left unread,
as one past the size limits is: its fonts give no widths. The scan
steps over dictionaries (`<<`) and comments as the CMap reader does.
- A composite font looks up at most `MAX_LOOKUPS` (16,384) of its codes
with a width, in `W` order, and keeps what it found among them.
Tests `a_to_unicode_map_with_a_long_destination_is_left_unread` and
`codes_past_the_most_looked_up_are_left`, each failing without its part.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A simple font in `WinAnsiEncoding` whose `ToUnicode` map was left
unread (past the size limits, or not a map at all) took its characters
from the encoding, as a font without a map does, so a code the map gives
another character lent its width to the encoding's. Only a font with no
`ToUnicode` entry now falls back to its encoding; one whose map can't be
read gives no widths.
Test `a_to_unicode_map_that_cant_be_read_gives_no_widths`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`Walk::add` compared each width a subset gave a character with the last
one kept, and kept the new one. Widths that drift a little at a time
(600, 600.8, 601.6) passed though the first and last are further apart
than `SAME_WIDTH`, and the same subsets read in another order gave none.
It now keeps the narrowest and widest width of each character and gives
the font none once they are more than `SAME_WIDTH` apart; the width kept
is the first one read.
Test `widths_that_drift_apart_over_several_subsets_give_none`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When several installed faces answer to a text document font record's
PostScript name and the record keeps no version (no key 5), type was set in
whichever copy loaded first. Two copies can share the PostScript name, family
and style and differ only in their widths (two releases of one font): the type
then set at other widths than the file's own page, and envelopes of it could
fail their drawn-art check. #6983 left this case out, as only the page's
widths tell such copies apart.
- `Opened::page_widths` (crates/pdf/src/page_widths.rs) reads the widths the
pages give the characters of each font they set type in, from the font
dictionaries alone and without importing any page: a simple font's
`Widths` from `FirstChar`, a composite font's descendant's `W` under an
`Identity-H`/`Identity-V` CMap, each code's character from the font's
`ToUnicode` map or, for a simple font without one whose `Encoding` is
`WinAnsiEncoding`, from that encoding (ISO 32000-1 9.6.2, 9.7.4.3, 9.10.3,
Annex D.2), by `BaseFont` without its subset tag. Zero widths (codes a
subset doesn't use) are left out; subsets that give a character two widths
give none.
- Its cost is bounded by the file: each resource dictionary is walked once,
however many pages and forms share it, within 65,536 entries for the whole
file, 256 fonts and 4,096 forms; a width array that fonts share by
reference is read once, and none past 4 MB of them; a `ToUnicode` map is
parsed once for all the fonts that name it, and one over 256 KB decoded,
or past 4 MB of maps in all (each charged at most what could be decoded
of it), is left unread. `cid_ranges` reads a `W` list's values as it
takes them instead of collecting the whole list. A font's widths are
shared, not copied.
- `postscript_face` (crates/eps/src/import/text.rs) takes, among the faces
of the record's name, the first that sets those characters (the first 512
in code-point order) each within 1/1000 em. With no widths, one face, a
version in the record, or no face that sets them all, the pick is the one
before. The face found first is checked before any other is loaded, and
the records of one name and version share their widths and their answer,
so each font resolves once whatever the number of records.
- The widths reach the text document through `Structure::page_widths` and
`Texts::with_page_widths`; the engine reads them once per open and passes
them to `ai_layers_alone`, `AiLayers::with_page_widths` and `ai_alone_with`
when it reads a `.ai`'s editing copy beside a PDF part (not for a
placeholder page).
- `without_subset_tag` replaces two copies of the subset-tag strip in the PDF
import, and `replacement` (a `ToUnicode` value that names no character) is
shared with it.
- A fuzz target feeds hostile font dictionaries, `ToUnicode` maps and forms
that draw themselves to the reader.
Measured on 224 users' files (used locally, never committed): 3 font records
in 3 files change copy, each now within 0.5/1000 em of its page; those 3
renders, and no others, change, all closer to the file's own page; envelopes
of type that open live go from 185 to 186, none fewer in any file; no file
opens another way.
Refs #6983
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A PDF/X-4 export wrote xmp:ModifyDate and xmp:CreateDate in its XMP
metadata but no xmp:MetadataDate. The PDF/X-4 metadata edit now adds
xmp:MetadataDate next to xmp:ModifyDate, with the same value, and grows
the stream's /Length to match. When the export dates the file as modified
later, post::modification_date already rewrites every xmp:MetadataDate,
so the two dates stay equal.
PDF/X-1a, PDF/X-3, PDF/A and plain PDF exports are unchanged.
A fill and a stroke at the same opacity below 1 were joined into one
type object whose opacity then applies to both together, losing the
darker overlap the file composites. stroke_filled now takes a stroke
only when the fill and the stroke are opaque.
An upright glyph filled and stroked was kept as an outline for the
reshaped-outline fallback while upright glyphs filled only were not;
it is no longer kept either, so such a line can't come in as the
outlines of its stroked glyphs alone.
Docs: the #8015 entries say what is left (translucent type, and a TJ
that starts a new line part way through).
- New tests: small opaque RGB and gray images are stored as RGB PNGs and an
image with a soft mask as RGBA; an image with one row more than the
pixel limit's square is left out with a warning.
- Gray images stay RGB on import, and a comment says why: a gray PNG
would make the image one that a fill color colorizes.
- Doc comments and the docs line give the limits in GiB, the line moves
next to the line about refused PDF parts, and it no longer gives a
timing.
A PDF, or a `.ai` read through its PDF part, was refused when one image
would decode to more than 1 GB, and the shared reader skipped images of
more than 2^28 pixels. On a 64-bit desktop build both limits are now 4 GB
and 2^30 pixels (`image_limits`), which `MAX_IMAGE_DECODED` and
`open_options()` share; 32-bit and web builds keep 1 GB and 2^28 pixels.
An image past the limit is refused with the same message.
An opaque image is encoded as an RGB PNG from its decoded samples instead
of building an alpha channel and an RGBA copy first.
Docs: docs/target-app-parity.md.
Part of #4366.