lightweight_pdf_layout/warnings.rs
1//! `plan/05-overflow-and-robustness.md` Grundprinzip 8: diagnostics instead
2//! of silent clipping. Collected during the layout pass and returned
3//! alongside the finished PDF bytes by the facade's
4//! `render_with_diagnostics()`, never separately (InDesign "Overset Text"
5//! anti-pattern).
6
7use lightweight_pdf_core::FontKey;
8
9#[derive(Clone, Copy, PartialEq, Eq, Debug)]
10pub enum LayoutWarningKind {
11 /// Text was cut off because its box was too small (`Overflow::Clip`).
12 TextClipped,
13 /// A container's content overflowed its box and was clipped.
14 ContentOverflow,
15 /// An atomic element bigger than a whole page was forced onto its own
16 /// page and clipped there (Grundprinzip 7).
17 ForcedPageBreak,
18 /// Header/Footer content was taller than its reserved band and got
19 /// clipped (band size is fixed, never grows, ADR-011).
20 HeaderFooterOverflow,
21 /// A character has no glyph in the resolved font and rendered as
22 /// `.notdef` (an empty box) instead. Deduplicated per (`ch`, `font`),
23 /// not per occurrence.
24 MissingGlyph { ch: char, font: FontKey },
25 /// A table row had more cells than the table declares columns — the
26 /// extra cells were dropped rather than rendered.
27 TableRowOverflow,
28 /// `Document::pdf_ua()` is set and an `Image` has no `.alt(...)` text
29 /// (issue #27) — it still renders (and still gets a `/Figure` tag),
30 /// just with an empty `/Alt`.
31 MissingAltText,
32}
33
34#[derive(Clone, Debug)]
35pub struct LayoutWarning {
36 pub kind: LayoutWarningKind,
37 pub page: usize,
38 pub element_hint: String,
39}