Commit Graph
702 Commits
Author SHA1 Message Date
.CooCoo 52b449ea70 Merge pull request #9099 from dotCooCoo/feat/print-per-job-settings
Print: Print as Bitmap prints at advanced.bitmapResolution
2026-12-05 05:15:32 -08:00
.CooCoo ce77145ac9 Merge pull request #10939 from dotCooCoo/fix/pdf-glyph-conflict-outline-note
PDF import: text outlined for a second glyph of a character says so
2026-12-05 04:36:32 -08:00
dotCooCoo 641b0145e4 PDF import: text outlined for a second glyph of a character says so
A line of type in a font the file carries is kept as outlines when it
uses a different glyph for a character than the rest of the file does in
that font, because the font kept with the document holds one glyph per
character. That line got the warning for scripts whose letters join, so
a Latin document reported Indic-style reshaping. It now gets its own
warning, which is also one of the warnings on outlines that a layered
.ai drops when no outlines are left. Type kept as outlines because it
would reshape keeps the old warning.
2026-12-05 03:16:41 -08:00
dotCooCoo 402ff3024e Fix #10902: PDF spot images and image masks keep their fill overprint
PDF import read overprint for paths and text only, so an image in a
Separation space or an image mask drawn under /op true opened knocking
out, and a separations export of the document lost the ink beneath it.
The interpreter reports the graphics state's overprint before each
image; the importer now keeps the fill's on the image's colorize paint,
as the .ai reader does.

- Each draw of an image takes the state of that draw, so one XObject
  drawn twice can overprint once and knock out once.
- A process color overprinting in mode 0 gives the same warning as a
  path does.
- A page whose paths can't be counted drops the paths' overprint and
  keeps the images'.
- An isolated group holding an overprinting image stays isolated.
- Images read inside pattern cells, soft masks and type 3 glyphs knock
  out, as paths there do.
2026-12-04 23:48:23 -08:00
dotCooCoo a8d0ac7caf Merge main into feat/print-per-job-settings 2026-12-04 16:44:13 -08:00
dotCooCoo ba27846c2a Merge main into feat/print-per-job-settings 2026-12-04 01:02:33 -08:00
yoriswindandFredApps aaf3cc87f0 PDF export: keep joins between opaque mesh patches smooth (#10372)
Co-authored-by: FredApps <[email protected]>
2026-12-04 09:43:27 +01:00
dotCooCoo 9c11c47f75 Doc tests: unsafe code is denied in doc tests too
Rustdoc builds each doc test as its own crate, without the workspace's
`unsafe_code = "deny"` and without a library's `#![forbid(unsafe_code)]`,
so a doc test holding an `unsafe` block passed `cargo test --doc`.

- Every library root now carries `#![doc(test(attr(forbid(unsafe_code))))]`,
  or `deny` in cad, eps and metafile, which rely on the workspace lint.
- `cargo xtask layers` reports a library whose doc tests are missing the
  attribute, or use `deny` where the library forbids unsafe code.
- AGENTS.md names the rule next to the `unsafe` allowlist.
2026-12-03 09:51:28 -08:00
.CooCoo 40060e0943 Merge pull request #10680 from dotCooCoo/fix/pdf-coverage-gaps-batch-11
Tests: cover PDF mesh shadings, restroked glyphs, repeated masks and spot midpoints
2026-12-03 02:03:39 -08:00
dotCooCoo c2d242eafa Tests: cover PDF mesh shadings, restroked glyphs, repeated masks and spot midpoints
Adds tests for PDF import and export paths that no test reached:

- A tensor-product patch mesh (type 7) imports as the gradient mesh of
  its boundary, the same mesh a Coons patch over that boundary gives.
- A triangle mesh (type 4) imports as one gradient mesh per triangle,
  each corner in its vertex's color.
- Tensor and triangle meshes over the 16,384-patch limit import as a
  flat gray with a warning.
- The last glyph of a run stroked again in another color splits off
  into its own run; the glyph before it keeps its stroke.
- A masked CMYK image drawn twice at two sizes keeps its opacity mask
  both times, fitted to each drawing; with a mask that hides nothing it
  has no mask either time.
- A one-spot-ink gradient with an off-center midpoint exports a stop at
  the midpoint with the mean tint, still as a Separation shading.

Each test fails with the code it covers broken.
2026-12-02 21:14:39 -08:00
dotCooCoo 03c3d8264b Tests: format the nested pattern and soft mask chains 2026-12-02 20:41:13 -08:00
dotCooCoo 95e2aa4804 Tests: PDF import limits and optional content membership
Add tests that fail when these PDF import paths break:

- Optional content membership dictionaries: AllOn, AnyOff, AllOff and
  the default AnyOn decide which marked art the page walk skips, with
  groups given as an array or a single reference. Each shown path keeps
  the spot ink the walk found it painted in.
- Tiling patterns and soft masks nested more than 8 levels deep open
  with their "nested too deeply" warnings.
- The ink-space scan stops 32 levels into an object and after 4,096
  spaces.
- A one-ink image of more than 2^26 pixels is refused before its
  samples are decoded.
2026-12-02 20:26:38 -08:00
dotCooCoo c4b6636b28 Merge main into feat/print-per-job-settings 2026-12-02 14:05:16 -08:00
dotCooCoo 540d7d9673 PDF/EPS/.ai import: store imported images with fast PNG compression
Opening a PDF, EPS or .ai file with images re-encodes each image, and
each image's opacity mask, as a PNG. Since the switch to the shared
image codec these PNGs were written with the codec's default
compression (deflate level 6) instead of fast compression. A PDF and
an .ai file each holding one image opened about 50 ms and 105 ms
slower than in 0.24.1.

PDF import and the EPS and .ai readers now each encode through one
helper that asks for PngCompression::Fast, the setting the SVG filter
raster already uses. The pixels are unchanged.

Tests check the zlib header of every PNG an import stores (RFC 1950
FLEVEL): PDF RGB, gray and image-mask images and a CMYK image's soft
mask; a PostScript RGB image and a masked CMYK image's mask; and .ai
RGB and Separation images with their masks, at full size and reduced.
2026-12-02 11:44:52 -08:00
dotCooCoo 1bb0553d8e Merge main into feat/print-per-job-settings 2026-12-02 02:20:58 -08:00
.CooCoo 22bc29d69d Merge pull request #10460 from dotCooCoo/fix/test-lint-mirror-false-alarms
xtask: test-lint mirror leaves out entry reads, never-run follows #[path] modules
2026-12-01 20:19:50 -08:00
dotCooCoo 6d175f9e64 Merge main into feat/print-per-job-settings 2026-12-01 20:03:49 -08:00
dotCooCoo 24bd16d3c2 Merge feat/scripts-api-d10-print-options into feat/print-per-job-settings
# Conflicts:
#	crates/engine/src/script/dom.rs
#	crates/engine/src/script/dom/print.rs
#	crates/engine/src/tests/script_print.rs
2026-12-01 20:03:46 -08:00
dotCooCoo 52d08f0f9c Tests: SVG, PDF and EPS tests check what they claim
Assertions that ran all() over a list that could be empty now check the
list's length first: mesh points, image inks, glyph origins, imported
text, the PDF mesh and arrowhead paths, and the resampled CMYK pixels.
An image that takes a Warp from its art style is checked to keep none of
the look's fills and strokes, instead of checking each of none.

The convolve-matrix tests check that the filtered rectangle is imported,
not only that the import returned Ok. The fan-out clip path test moves
to a unit test that counts the clip paths read. The self-nesting symbol
test checks that the other symbol comes back. The EPS level and preview
id test checks the param values and the trimming and case rules instead
of looping over every value. The ignored PDF text-heavy timing run says
why it is ignored.

A gradient that repeats or reflects with no stops now paints as one
that pads. Before, PDF export wrote it as two 160 by 160 images and EPS
wrote three runs of a conic where one that pads writes one;
`Gradient::is_spread` is false without stops. `paint.setFill`'s params
still report the spread.
2026-12-01 17:38:19 -08:00
dotCooCoo a61a9ba254 Merge main into fix/test-lint-mirror-false-alarms 2026-12-01 16:17:26 -08:00
.CooCoo 4596f1a8be Merge pull request #10374 from dotCooCoo/fix/swallowed-regression-guards
Tests: guards check the environment, not the output under test
2026-12-01 14:10:23 -08:00
dotCooCoo adef85f5f0 Merge main into chore/never-run-test-allows 2026-12-01 03:42:46 -08:00
.CooCoo c3c545dc69 Merge pull request #10430 from dotCooCoo/fix/format-test-tolerances
Tests: format tests check exact values instead of wide tolerances
2026-12-01 03:16:25 -08:00
.CooCoo fac0d0fc80 Merge pull request #10385 from dotCooCoo/fix/behavior-tests-for-source-greps
Tests: check the PDF key and Math.random seeds by behavior
2026-12-01 02:59:13 -08:00
dotCooCoo b2e8b5637e Merge main into chore/never-run-test-allows 2026-12-01 02:55:37 -08:00
.CooCoo 295da28ec5 Merge pull request #10420 from dotCooCoo/fix/pdf-read-counter-address-reuse
PDF: count test reads of a buffer from a mark, not over its address's whole history
2026-12-01 02:32:29 -08:00
dotCooCoo 9730c888fb Tests: seed the PDF file key test through protect
The test called Entropy::seeded directly, so it still passed if export
stopped reading the OS random source. Entropy::new now reads the OS
bytes and the time through seed_sources(), which a test can set for
its thread, and the test runs protect with fixed OS bytes, other OS
bytes and a failed OS read. The OS read in vectorcraft-js's os_random()
is now one function for tests and builds alike.
2026-12-01 02:17:47 -08:00
dotCooCoo d0cf7f09ec Tests: format tests check exact values instead of wide tolerances
The PDF, EPS, SVG mesh, metafile hatch and distorted-image tests now
assert the values the input gives: the Letter page a page without area
falls back to, the H glyph's box from its font metrics, the middle gray
of each mesh piece, the 8 of 64 hatch pixels, and the bounds of the
placement taken at the image's center.
2026-12-01 02:05:29 -08:00
dotCooCoo 010367e39e Tests: allow the 26 Windows and macOS tests that CI never runs
Each test that a cfg limits to Windows, macOS or a case-insensitive file
system gets a `test-lint: allow never-run` line naming its platform, so
`cargo xtask test-lint` no longer reports them. The tests are unchanged
and still run on their own platform.
2026-12-01 01:46:09 -08:00
dotCooCoo 68dbba0b92 PDF: count test reads of a buffer from a mark, not over its address's whole history
reads_of counts reads by buffer address and never forgets them, so a buffer
allocated where another test's freed buffer was read starts with that count.
linked_pages_read_the_file_once_and_a_blank_page_keeps_its_crop_box asserted
reads_of(&blob) == 0 and failed once that way under 16 test threads.

Each read now gets a sequence number. read_mark returns the next one and
reads_of_since counts only the reads at or after a mark. The linked-pages test
takes a mark before opening the file.
2026-11-30 23:05:46 -08:00
dotCooCoo 3f21a06bed Tests: cover broken hex strings in the stream scan and restricted file fonts
A hex string broken by a byte that is neither a hex digit nor white space
is no string: the hostile-input scan goes on from the next byte, so a
cross-reference stream after it is still read. A font a PDF carries with
restricted license flags (OS/2 fsType 0x0002) keeps drawing its type, and
a PDF saved from the document draws that type as outlines with the license
warning instead of embedding the font again.
2026-11-30 23:03:07 -08:00
dotCooCoo c47fdb8974 Tests: check the PDF key and Math.random seeds by behavior
The PDF encryption and Math.random seed tests read their source files
and searched for names. They now build the seed from given OS bytes:
equal bytes give an equal stream, other bytes give another stream, and
a failed OS read is an error for the PDF key. Mixing any other source
into either seed fails the tests.

The PDF seed is split into Entropy::seeded, which takes the OS bytes
and the time, and the module doc now names the OS random source.
2026-11-30 22:58:06 -08:00
dotCooCoo 1dbbf87436 Tests: guards check the environment, not the output under test
Several tests returned early when the code under test gave back nothing,
so the regression they guard against passed. Each of those guards now
checks only what the host provides (an installed face, the bundled
fonts), and the output itself is asserted:

- PDF live text: the lam-alef face is no longer picked by whether its
  type imports (#6072); Insert Kashidas asserts the kashida and the
  imported type.
- Effects and Expand Appearance on type assert the outlines and the
  drawn type when the default face is installed.
- The OpenType panel's Stylistic Sets test asserts sets with the
  bundled fonts.
- Thumbnail worker tests assert that the worker starts; the memory
  peak test asserts a reading.
- The json2 test checks the interpreter's Date, replace and RegExp on
  every run, before looking for json2.js.
- Devanagari arrow keys and the Arabic narrow-area wrap assert the
  layout they set up.
2026-11-30 21:56:24 -08:00
BFlat cf2d168d49 PDF import: inline images with the same dictionary keep their own pixels (#10313)
An inline image has no object of its own, and the interpreter keys an image
by its dictionary alone, so every inline image of one size and encoding got
the key of the first one and was imported with its pixels: Type 3 glyphs drawn
as inline stencil images came in as the wrong letters. An inline raster image
is now keyed by its samples too, and a stencil image by its decoded pixels.

Fixes #9247
2026-12-01 05:05:57 +07:00
dotCooCoo 20e4e1bf58 Merge feat/scripts-api-d10-print-options into feat/print-per-job-settings 2026-11-30 11:19:45 -08:00
dotCooCoo 42cd387802 Print: Print as Bitmap keeps its resolution at a print scale
Print as Bitmap rendered at bitmapResolution in document points, so a
job printed at 200%, or enlarged by Fit to Page, printed the image at a
lower resolution than asked and the pixel-limit warning did not name it.
The render now takes the page's horizontal and vertical print scale into
account, and the warning and the preview note compare the resolution on
paper.
2026-11-30 00:22:37 -08:00
dotCooCoo c1eb29c054 Docs: doc comments name U+FFFD in place of the literal character
Two doc comments held a literal U+FFFD replacement character, which
SonarCloud reports as "Invalid character encountered". They now write
it as `\u{FFFD}`:

- crates/ui-egui/src/panels/actions/playback.rs (`shown_text`)
- crates/pdf/src/tests/realtext.rs (the #708, #811 test)
2026-11-29 16:39:26 -08:00
dotCooCoo 976f1a4d91 Merge main into feat/print-per-job-settings
Ports the print option classes to main's reflected members; reflect leaves out the options that take only their default.
2026-11-28 20:08:31 -08:00
jmvergesandClaude Opus 5.5 cbfb26b9ab Merge main (89a5b64170) into the font width import branch
Main now reads the editing copy decoded as its streams are read
(#9922: ai_alone_decoded, ai_layers_alone_decoded, AiLayers::decoded)
and renamed the text document's patterns to paints (#9782:
text_patterns, Texts::with_paints). The decoded entry points take the
PDF part's widths as the ones they wrap did, AiLayers::decode goes
through AiLayers::decoded, and the text document still takes the widths
when it is first read, before its paints. The docs keep both sides'
entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-28 20:50:55 +00:00
.CooCoo 4fe3b646f7 Merge pull request #9937 from dotCooCoo/train/carry9168
PDF: PDF/X-4 exports declare the identification namespace on the XMP description (carries #9168)
2026-11-28 08:36:48 -08:00
dotCooCoo b464b1ecad PDF: check that the PDF/X-4 XMP packet stays well-formed
The PDF/X test now asserts that the outer description declares the
pdfxid namespace exactly once, and that the edited packet parses with
the strict XML parser that File Info uses to read it back.
2026-11-28 08:08:13 -08:00
dotCooCoo 09c619f63e Merge main into train/carry9168 2026-11-28 07:34:31 -08:00
dotCooCoo 4d1f6cc249 .ai import: editing data whose streams pass 256 MiB opens with its layers
The private data streams of a .ai file, or of a PDF saved with its
editing data, were joined into one buffer of at most 256 MiB before
they were decoded, while the decoded editing data may take up to an
eighth of installed memory (512 MiB to 2 GiB). A file whose streams
passed 256 MiB opened as its PDF part without a note, and a file whose
PDF part can't be read failed with "it is larger than 256 MB".

The streams are now read one after the other and decoded as they are
read, so they are never joined. The decoded data keeps its limit, and
no more of the streams is read than that limit and a sixteenth more.
The data is decompressed after the first compression marker in it.
2026-11-28 05:19:31 -08:00
.CooCoo 39f317a0c6 Merge pull request #9840 from dotCooCoo/fix/engine-tests-count-work
Tests: bounded-work checks count the work instead of timing it
2026-11-28 00:16:46 -08:00
dotCooCoo f23186d1d4 PDF import: count function evaluations on an import that stops part way
The work count recorded a PDF import's function evaluations only after
the last page, so an import that stopped on a later page (a page whose
scan or drawing fails) recorded none of the evaluations its earlier
pages took. Each page now adds its evaluations right after it is drawn,
before any error returns, and each evaluation is counted once.
2026-11-27 21:47:49 -08:00
.CooCoo b7cec34427 Merge pull request #9778 from dotCooCoo/fix/pdf-cmyk-count
PDF export: the CMYK document warning counts only RGB images written to the file
2026-11-27 21:41:17 -08:00
.CooCoo 94fa38479f Merge pull request #9861 from dotCooCoo/fix/pdf-import-work-counters
PDF import: complexity tests count the work done instead of timing it
2026-11-27 21:38:07 -08:00
dotCooCoo 5466829792 PDF import: complexity tests count the work done instead of timing it
The four tests of the pre-open stream scan and the page hash test
asserted elapsed time (5 s and 60 s), so a loaded machine could fail
them and a slower but still bounded scan could pass them.

- streams.rs: a test-only counter adds up the bytes the scan looks at:
  in each helper that walks the file, in each charge to the scan's
  budget, and once for each step of the main reading. The tests assert
  at most 32 bytes looked at for each byte of the file. The largest
  case today looks at 21.
- editing.rs: a test-only counter adds up the page content the hash
  decodes. The test asserts no more than the hash limit plus the one
  stream that goes past it.

Each counter assertion fails on a broken version: strings read to the
end of the file instead of 64 bytes (131,076 bytes a byte), each
stream keyword reading back 64 KiB (7,937 bytes a byte), and every
page decoding the shared stream again (300 MiB decoded).
2026-11-27 18:03:03 -08:00
dotCooCoo 8c2ab73b81 Tests: bounded-work checks count the work instead of timing it
Six engine tests guarded against quadratic or unbounded work by timing
it (under 2, 10, 30 or 60 seconds) or by printing how long it took. A
slow or loaded machine could fail them, and a regression that stayed
under the bound passed. Each now counts the work the guarded code does
and compares it with a smaller input or with the code's own limit:

- An unknown command id or parameter key of 200,000 characters compares
  no more characters than one of 20 (edit-distance cells).
- A Word .doc with 20,000 hidden paragraphs reads at most one more Prl
  per paragraph than one with a single paragraph, and each style's
  properties are read once.
- One function-based shading filling 5,000 paths takes no more function
  evaluations than filling one, and twenty stay within the import's
  evaluation budget.
- A form decoding to 64 MiB drawn 1,000 times is walked no further than
  the page's form-content limit and one more form.
- A blend of 998 steps measures no more laid steps per object than a
  blend of 3, and one of 1,500 steps is not laid out.
- Retype of a tracked line of 450 glyphs lays out at most 20 times the
  glyphs a line of 45 does.

The counters are test-only: thread-local cells in the engine under
cfg(test), and in vectorcraft-pdf (read-count feature) and
vectorcraft-eps (new work-count feature), which the engine enables in
its dev-dependencies only. Retype's layout calls go through one helper
that counts them.
2026-11-27 16:20:23 -08:00
jmvergesandClaude Opus 5.5 3ce7a70811 PDF export: a black-and-white colorized image is never smoothed
A 1-bit image mask opens as a grayscale image of black and white pixels
colorized by its fill color. The PDF export wrote it as its ink with the
pixels as an 8-bit soft mask and /Interpolate true on both. A RIP that
honors /Interpolate smooths the mask and grays its edges, so where the
same mask is drawn over itself in another ink, as separated garment art
stacks its plates, the ink below shows along every edge. The file's own
PDF part and the EPS export keep the mask hard.

A colorized image whose coverage is only 0 or 255 (the test the
Monochrome compression settings already use, now
`images::bilevel_coverage`) is written without /Interpolate. Grayscale
images keep it. krilla has no 1-bit soft mask or /ImageMask, so the
mask stays 8-bit and just isn't smoothed.

The pixelated colorized image test now uses gray pixels, since a
black-and-white image no longer asks for smoothing whether or not it is
pixelated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-27 22:35:24 +00:00