Expand description
Batteries-included PostScript Level 3 interpreter.
This crate provides a simple, high-level API for rendering PostScript and
EPS files. All resources (35 fonts, init scripts, encodings, ICC profiles)
are embedded in the binary — no external resources/ directory needed.
§Quick Start
let mut interp = stet::Interpreter::new();
let pages = interp.render(b"%!PS\n100 100 moveto 200 200 lineto stroke showpage", 300.0).unwrap();
// pages[0].rgba — RGBA pixel data
// pages[0].width, pages[0].height — dimensions in pixels§Output Modes
| Method | Returns | Feature |
|---|---|---|
Interpreter::render | RGBA pixels + display list | render (default) |
Interpreter::render_to_display_list | Display lists only | always available |
Interpreter::render_to_pdf | PDF bytes | pdf-output (default) |
Interpreter::exec | Nothing (side effects only) | always available |
§Configuration
let mut interp = stet::Interpreter::builder()
.no_icc() // disable ICC color management
.suppress_output() // silence PS print/==/= operators
.build();§Diagnostics
A render that returns no pages is not necessarily an error. The common
cause is a program that painted marks and then ended without calling
showpage: the page is discarded, and the render returns Ok(vec![]) —
an empty page list that reads like a legitimate result.
Interpreter::warnings tells the two apart.
let mut interp = stet::Interpreter::new();
let pages = interp.render(b"%!PS\n0 0 100 100 rectfill", 72.0).unwrap();
if pages.is_empty() {
for w in interp.warnings() {
eprintln!("warning: {}\n {}", w, w.hint());
}
}See diagnostics for the warning types.
§Feature Flags
Both features are enabled by default. Use default-features = false for
a minimal build that only supports display list output.
| Feature | Adds | Extra dependency |
|---|---|---|
render | render() — RGBA pixel output | stet-render (tiny-skia) |
pdf-output | render_to_pdf() — PDF output | stet-pdf |
Re-exports§
pub use diagnostics::ExecWarning;pub use diagnostics::ExecWarningKind;
Modules§
- diagnostics
- Execution-time diagnostics — non-fatal problems noticed while running a PostScript program that would otherwise be silent.
- embedded_
resources - Embedded resource files for the stet facade crate.
Structs§
- Display
List Page - A page’s display list with dimensions (before RGBA rendering).
- IccCache
- ICC color profile cache and transform manager.
- Image
Cache - Pre-converted RGBA image data cache, indexed by display list element index.
- Interpreter
- A fully initialized PostScript interpreter.
- Interpreter
Builder - Builder for configuring an
Interpreterbefore creation. - Prepared
Display List - Pre-computed metadata for fast viewport rendering.
- PsContext
- PsDisplay
List - An ordered list of drawing operations for a single page.
- Rendered
Page - A rendered page with display list and optional RGBA pixel data.
Enums§
- Display
Element - A single recorded drawing operation.
- Stet
Error - Error type for interpreter operations.
Functions§
- build_
icc_ cache_ for_ list - Pre-downsample an image when the transform indicates significant downscaling.
- prepare_
display_ list - Precompute display list metadata for fast viewport rendering.
- ps_exec
- Tokenize a byte stream and execute it.
- render_
region_ prepared - Render a rectangular viewport region using precomputed metadata.
- render_
to_ rgba - Render a full-page display list to RGBA pixels using the banded parallel renderer.
- viewport_
band_ count - Compute the number of bands and band height for viewport banding.