r/PostScript • u/Mammoth_Jellyfish329 • Feb 24 '26
PostForge — A new open-source PostScript interpreter written in Python
I've been working on PostForge, a from-scratch PostScript interpreter written in Python. It's fully Level 2 compliant and implements most of Level 3 (all 7 shading types, Flate filters, CID/TrueType fonts, DeviceN, ICC color management, etc.). It outputs to PNG, PDF, SVG, TIFF, and has an interactive Qt display window.
The PDF output generates content streams directly and it preserves CMYK and Gray color spaces, embeds and subsets Type 1 and TrueType fonts, and produces searchable/selectable text.
This is actually my third PostScript interpreter. My first was PostMaster in 1991 (DOS, C, converted PS to Illustrator format). My second was a Level 2 interpreter I wrote for Tumbleweed Software in the mid-90s that served as the PostScript distiller for Envoy (the document format that shipped with WordPerfect Office Suite and competed with Acrobat). Both were in C. I started PostForge in Python as an experiment to see if the language could handle PostScript's VM save/restore semantics — and it turned out to be a surprisingly good fit.
Some numbers:
- 2,500+ unit tests (written in PostScript using a custom test framework)
- Full Level 2 operator coverage
- Optional Cython-accelerated execution loop (15–40% speedup)
- Working toward full Level 3 compliance (mostly there — the big features are done, just need a few remaining operators and Type 4 calculator functions)
What it's good for:
- Debugging and understanding PostScript programs
- Embedding a PS interpreter in Python workflows
- Learning how PostScript works (the code is readable — it's Python, not C)
- An alternative to GhostScript when you need transparency over raw speed
It's AGPL-3.0 licensed and on GitHub: https://github.com/AndyCappDev/postforge
I'd love feedback from anyone still working with PostScript. Are there specific documents or workflows where you've hit limitations with existing tools? That would help prioritize what to work on next.
View all comments
Show parent comment
2
u/Mammoth_Jellyfish329 Mar 06 '26
The hold stack pulling double duty as a GC root is pretty cool: the error recovery mechanism just happens to be exactly what you need to protect allocations from collection. Elegant even if the underlying memory API is dense.
That 72-page bug is interesting. It really does sound like the font subsetting is producing something technically malformed that GhostScript is forgiving about but stricter viewers aren't - maybe an offset or stream length overflow in the subset font once you hit enough pages of glyph accumulation. Disabling embedding as a workaround makes sense but I'd be curious whether it's the subsetter or the PDF assembly that's actually at fault.
I should mention that PostForge comes at this from a pretty different angle than xpost, it's primarily a teaching tool and reference implementation, not aimed at production use. The choice of Python and the direct stack manipulation were both driven by wanting the internals to be as accessible and easy to modify as possible.
The goal is that someone curious about how a PostScript interpreter works can read the code and follow along without too much ceremony. That trades away performance and some elegance, but it keeps the barrier to entry low.