stet-graphics
The graphics foundation for the stet PostScript and PDF rendering stack — colours, the display list, ICC profile management, and the mesh / patch shading parsers.
Only depends on stet-fonts, so it's
usable on its own if any of these subsystems is what you actually want:
- ICC colour management (CMYK↔sRGB, image bulk conversion, BPC) via
moxcms. - Parsers for PDF Type 4–7 shading data (Gouraud mesh, Coons / tensor patch).
- The
DisplayList/DisplayElementtypes — both the stet PostScript interpreter andstet-pdf-readeremit into this format, so downstream consumers (custom output devices, PDF rewriters, diff tools) use these types to stay compatible.
If you just want to render PS or PDF, use the
stet facade crate instead.
What's inside
| Module | Purpose |
|---|---|
color |
DeviceColor (sRGB + lossless native CMYK), LineCap, LineJoin, FillRule, DashPattern, and CIEBasedA/ABC/DEF/DEFG parameter types |
device |
FillParams, StrokeParams, ImageParams, ClipParams, AxialShadingParams, RadialShadingParams, MeshShadingParams, PatchShadingParams, PatternFillParams, TextParams, TransferState, HalftoneState, BgUcrState, plus PageSink / PageSinkFactory traits |
display_list |
DisplayList, DisplayElement, GroupParams, GroupColorSpace, SoftMaskParams, MaskRaster — the flat painter-order intermediate representation every stet output device consumes |
icc |
IccCache, BpcMode, ProfileHash, find_system_cmyk_profile_bytes() — profile registration, SHA-256 deduplication, cached f64 and 8-bit transforms, black-point compensation |
mesh_shading |
Binary decoders for PDF shading types 4 (free-form mesh), 5 (lattice-form mesh), 6 (Coons patches), 7 (tensor patches) |
See the Display List Reference for complete element and parameter documentation.
Standalone use
[]
= "0.1"
ICC colour management
use IccCache;
let profile = read?;
let mut cache = new;
cache.load_cmyk_profile_bytes;
// CMYK → sRGB in [0, 1]
if let Some = cache.convert_cmyk
// Bulk image conversion (8-bit) — fast path for rasterization.
// `src` holds CMYK bytes; `dst` receives 8-bit sRGB.
// cache.convert_image_8bit(&src_cmyk, &mut dst_rgb, ...);
# Ok::
Black-point compensation is on by default; opt out with
IccCache::new_with_options(IccCacheOptions { bpc_mode: BpcMode::Off, .. }).
Parse a PDF Type 6 (Coons patch) shading
use parse_type6_patches;
// `data` is the decoded binary stream from a PDF shading dictionary.
// The bits-per-* arguments come from the shading dict's
// /BitsPerCoordinate, /BitsPerComponent, and /BitsPerFlag entries; the
// `decode` slice holds the flattened /Decode array (x range, y range,
// then one range per colour component).
let patches = parse_type6_patches;
for patch in &patches
# Ok::
Consume a display list
The DisplayList type is shared between stet and stet-pdf-reader, so a
custom output format can iterate over elements without caring which
source produced them:
use ;
License
Apache-2.0 OR MIT