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. - Rich
Line - One wrapped line of a
Text::rich(..)paragraph.heightissize * line_heightof the line’s tallest word (not a fixed, whole-paragraph value like plainText’sline_height_pt);ascent_ptis that same tallest word’s ascent, in points — every word on the line shares this one baseline reference regardless of its own size, which is what keeps mixed sizes visually aligned on one baseline instead of each hanging from its own. - Size
- Styled
Word - One word plus the style it should be drawn in — the atomic unit
wrap_spansarranges intoRichLines. - TocHeading
- One heading, discovered from the pre-layout
Elementtree by [prepare_toc] — everything aTableOfContentsentry needs except the page number (added later, pass 2 only, viaLayoutCtx::toc_heading_pages).
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). - Struct
Role - The PDF standard structure types (ISO 32000-1 14.8.4, Table 333/334)
this crate tags content with — no
RoleMapneeded since all of these are standard types.Groupingroles (seeStructRole::is_grouping) nest childStructElems and own no marked content of their own;Artifactis excluded from the structure tree entirely (watermarks, running headers/footers — PDF/UA pagination artifacts, not content).
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
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.