Commit Graph
7 Commits
Author SHA1 Message Date
dotCooCoo a6b7bdce3e ps: write numbers from their rounded integers instead of the float formatter
push_num_places now writes the digits of round(v * 10^places) directly
when that integer is below 2^52 in magnitude, placing the decimal point
and trimming fractional zeros itself. Below 2^52 the integer is exact
and dividing it by 10^places lands within half a decimal step of the
exact quotient, so the text is the same as the formatter's. NaN,
infinities, scaling overflow and larger rounded values take the
existing formatter path unchanged. Requests for more than nine places
are still clamped to nine first.

Tests compare the output with the formatter path for places 0 to 12
over fixed boundary values (negative zero, ties, 1e15, 2^52, f64::MAX,
non-finite values) and about 144,000 values in all (about 48,000
generated, plus the neighboring bit patterns of each). Widening the
limit to 2^54 makes the comparison fail, for example
-1709448349065955.5 at one place.

On 1,200,000 path coordinates at four places (release build, wall
clock on a Linux host running other builds at the same time, seven
alternating runs), the formatter path took 362 to 373 ms and the
integer path 38 to 44 ms.
2026-11-16 14:08:31 -08:00
FredApps a80c0f25f1 ps: add a write feature for PostScript tokens (#778, #790) (#1840)
* ps: add a write feature for PostScript tokens

Numbers, strings, matrices, path data and Flate, so apps can emit a
PostScript or EPS program without owning the token serializer. Path and
paint operators can use the Language Reference names or the one-letter
names a bound prolog defines. Container concerns stay in craft-eps.

Part of #778 and #790.

* ps: tighten write-feature number trimming and Flate bounds

- Require flate2 1.1.10 so inflate rejects an incomplete zlib stream.
- Trim trailing zeros only when the token has a decimal point, so
  places=0 keeps integer zeros at the 1e15 boundary.
- Use saturating_add when bounding inflate, so max = u64::MAX does not
  overflow.
2026-11-16 07:12:00 -05:00
FredApps c0f7be37f1 Merge pull request #1694 from storytold/codex/ps-actualtext-scope
Keep synthesized PostScript text spans inside clip scopes
2026-11-16 00:02:17 +01:00
Dylan M. Taylor 808730f49b ps: preserve reencoded glyph names in fallback fonts 2026-11-15 14:57:56 -05:00
Dylan M. Taylor 1fdb3934b5 ps: check selected glyphs before text labeling 2026-11-15 18:09:31 +00:00
Dylan M. Taylor 204240ad80 ps: keep synthesized text spans inside clip scopes 2026-11-15 18:07:43 +00:00
41fb227542 feat(ps): add bounded shared PostScript EPS reader (#1276)
* feat(ps): add craft-ps with an EPS reader (read feature)

The reading half of craft-ps (#115): a clean-room PostScript interpreter
that runs an EPS and returns what it paints as a one-page vector PDF of
its bounding box, colours kept, so apps can draw and export EPS as a
placed PDF. Moved from DesignCraft (storytold/designcraft, where it was
written for placed EPS), with its app-specific names made neutral.

Written from the PostScript Language Reference (3rd ed.), the EPS
specification, the Type 1 Font Format and Adobe TN 5012/5176/5177.
Covers the language, paths, clipping, strokepath, device/Separation/
DeviceN/Indexed/ICCBased/Lab colour, images with lazily decoded filters,
shadings 1-7 and patterns, and Type 1/3/42/CFF/CID text through CMaps,
horizontal and vertical.

Bounded: each operator charges work proportional to its operands
against the step limit as it goes, every byte read or decoded counts,
copies count against the memory cap; defaults 50 M steps / 1 GiB, and
20 M / 256 MiB on wasm32. No panics (deny lints, fuzzed in debug
builds). 34 tests, the Type 42 one on a TrueType font built in the
test. No new external crates: pdf-writer, miniz_oxide, weezl, skrifa
and kurbo are already locked at these versions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* clippy(ps): document stateful decoder complexity

* fix(ps): bound huge arc angle normalization

* fix(ps): preserve EffectCraft EPS text and limits parity

* fix(ps): address interpreter review findings

* fix(ps): preserve composite glyph paint order

* fix(ps): address interpreter review findings

* fix(ps): bound filter buffers and preserve file aliases

* fix(ps): make predictor allocation fallible

---------

Co-authored-by: markus.doebele <markus.doebele@top21.sh>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 06:10:27 -05:00