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
- Layout
Ctx - Layout
Warning - Page
Render - Paginated
Document - 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
RenderNodetree into content-stream ops. - Size
Enums§
- Layout
Result - 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,ColumnandTableproduceSplitin V1. - Layout
Warning Kind - Render
Node - Positioned, resolved layout output ready for the facade to translate
into
lightweight-pdf-writercontent-stream operations. Never seen bylightweight-pdf-writerdirectly (plan/00a-contracts-and-artifacts.mdpoint 3).
Traits§
- Font
Metrics - Per-font metrics, normalized to 1000 units-per-em (PDF/Type1
convention).
lightweight-pdf-layoutnever sees font bytes — only this. - Font
Resolver lightweight-pdf-layout’s only dependency on fonts: given aFontKey, hand back metrics. Implemented by the facade crate, which bridges tolightweight-pdf-fonts::FontData(ADR-010).- Layoutable
measure/layout. Implemented for every concrete element type (notElementvariants withtodo!(), since all V1-through-Phase-2 variants are implemented) plus a dispatching impl onElementitself so containers can recurse overVec<Element>children.
Functions§
- align_
offset - Just used inside
Row/Columncross-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
RenderNodeper page. - text_
width_ pt - wrap_
text - Wraps
texttomax_widthpoints. Explicit\nin the source text start a new paragraph/line unconditionally.