Skip to main content

Crate lightweight_pdf_layout

Crate lightweight_pdf_layout 

Source
Expand description

Layoutable trait, pagination and text wrapping for lightweight-pdf. Knows lightweight-pdf-core’s element types, but nothing about lightweight-pdf-writer or fonts beyond the FontResolver contract (ADR-010).

Structs§

Constraints
LayoutCtx
LayoutWarning
PageRender
PaginatedDocument
Rect
Coordinates are page-relative, top-down (x grows right, y grows down from the top of the body/header/footer band) — a purely internal layout convention. The facade converts to PDF’s bottom-left origin only at the very end, when translating a RenderNode tree into content-stream ops.
Size

Enums§

LayoutResult
Result of laying an element out into a bounded area: either it fully fit, or the fitting part plus a materialized remainder element for the next page. Text, Column and Table produce Split in V1.
LayoutWarningKind
RenderNode
Positioned, resolved layout output ready for the facade to translate into lightweight-pdf-writer content-stream operations. Never seen by lightweight-pdf-writer directly (plan/00a-contracts-and-artifacts.md point 3).

Traits§

FontMetrics
Per-font metrics, normalized to 1000 units-per-em (PDF/Type1 convention). lightweight-pdf-layout never sees font bytes — only this.
FontResolver
lightweight-pdf-layout’s only dependency on fonts: given a FontKey, hand back metrics. Implemented by the facade crate, which bridges to lightweight-pdf-fonts::FontData (ADR-010).
Layoutable
measure/layout. Implemented for every concrete element type (not Element variants with todo!(), since all V1-through-Phase-2 variants are implemented) plus a dispatching impl on Element itself so containers can recurse over Vec<Element> children.

Functions§

align_offset
Just used inside Row/Column cross-axis alignment.
paginate
paginate_body
Repeatedly lays the document body out into an identical, fixed-size box per page until every child has been placed. Returns one RenderNode per page.
text_width_pt
wrap_text
Wraps text to max_width points. Explicit \n in the source text start a new paragraph/line unconditionally.