Expand description
A rasteriser for the pdf2 crate: paths, clips, transforms, dashes and the
beginnings of a content-stream interpreter.
The walker reuses pdf2’s tokenizer and document model — there is no second
PDF parser here. What it can draw today:
- path construction (
m,l,c,v,y,h,re) in user space, with the CTM applied at flattening time; - fills with the non-zero (
f,F,B) and even-odd (f*,B*) rules; - strokes with butt, round and square caps, round joins, and dash patterns
(
d) with a phase; - clipping (
W,W*) as a per-pixel mask that nestedq/Qrestores; - colour operators
g/G,rg/RGand the naivek/Kconversion.
Not yet drawn, and reported per page in Report::unsupported instead of
failing: text and images. Rendering is deliberately without anti-aliasing
for now: coverage is decided at pixel centres, which keeps the golden images
exact and the scanline code small.
Structs§
- Canvas
- An RGBA8 raster.
- Clip
Mask - A per-pixel inclusion mask produced by clipping.
- Color
- A colour with straight (non-premultiplied) components.
- Dash
- Line-dash pattern, in user-space lengths.
- Glyph
- One glyph’s outline in em units: y grows upwards, the baseline is y = 0 and one em is 1.0.
- Image
- A decoded image: width, height and one colour per pixel, top row first.
- Matrix
- A 2×3 affine transform, in the order PDF writes it:
a b c d e f. - Path
- A path in user space.
- Point
- A point in user or device space.
- Rect
- A rectangle in PDF user space:
[x0 y0 x1 y1]. - Render
Options - What a page render should look like.
- Rendered
Page - A rendered page.
- Report
- What happened while rendering, beyond the pixels.
- Subpath
- A connected run of segments.
Enums§
- Cap
- How a stroked path ends.
- Error
- Every failure mode the crate reports.
- Font
- A resolved font ready to place glyphs.
- Join
- How stroked segments meet.
- Segment
- One segment of a subpath.
Functions§
- clip_
mask - Rasterise polygons into a clip mask of the given size: inside where the fill rule says painted, outside everywhere else.
- encode_
png - Encode the canvas as a PNG.
- fill_
polygons - Fill polygons with
color, restricted tomask. - render_
page - Rasterise one page.
- render_
page_ number - A document, page number (zero based) and rasterisation scale in one call.
Type Aliases§
- Result
- Result type used throughout the crate.