Skip to main content

fleuron/
lib.rs

1//! fleuron: paged-media layout for book-shaped documents.
2//!
3//! The pipeline is one-way:
4//!
5//! ```text
6//! content tree + style tree ─► box tree ─► line layout ─► fragmentation ─► pages
7//! ```
8
9#![deny(missing_docs)]
10
11pub mod content;
12pub mod fonts;
13pub mod images;
14pub mod layout;
15pub mod linebox;
16pub mod lines;
17pub mod pages;
18pub mod pdf;
19pub mod session;
20pub mod style;
21pub mod wire;
22
23/// Non-fatal problems surfaced during style compilation, layout, or
24/// fragmentation: unsupported CSS, missing fonts, low effective DPI…
25#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
26pub struct Warning {
27    /// What went wrong, in one line.
28    pub message: String,
29    /// Source location when one exists (CSS line, content node id).
30    pub origin: Option<String>,
31}
32
33/// Everything the engine produces for one run: pages plus diagnostics.
34#[derive(Debug, PartialEq, serde::Serialize, serde::Deserialize)]
35pub struct LayoutOutput {
36    /// The typeset pages, in reading order.
37    pub pages: Vec<pages::Page>,
38    /// The fonts this run used, indexed by `font_id`: both painters
39    /// and the PDF writer resolve ids through this table.
40    pub fonts: Vec<fonts::FontRefEntry>,
41    /// The images this run placed, indexed by `DrawItem::Image.asset`.
42    /// Layout sized them from their headers and decoded nothing; a
43    /// painter takes the url back to its own pixels.
44    pub assets: Vec<images::Asset>,
45    /// Everything the run had to complain about.
46    pub warnings: Vec<Warning>,
47    /// The links a reader follows and the outline of the headings.
48    /// The PDF writer reads it. The wire does not carry it.
49    #[serde(default)]
50    pub navigation: pages::Navigation,
51}