pagelayout

    Paginated document layout engine: format-neutral page-model IR with SVG/PDF backends.

    layout
    pagination
    docx
    svg
    pdf
    typesetting
    Download zip
    Version
    0.7.0
    License
    Apache-2.0
    Last updated
    10 hours ago
    Downloads
    78

    #pagelayout

    Paginated document layout engine. Frontends (DOCX first) produce engine input; the engine measures, line-breaks, and paginates into a format-neutral page-model IR — pages of positioned glyph runs, rectangles, images, and link regions; backends (SVG first, then PDF via pdflite) transcribe the IR. Design record: docs/page-layout-engine.md at the repository root.

    Coordinates are points, y-down, origin at the page's top-left; text is positioned by baseline, and glyph runs carry their own advances so backends never re-measure.

    ///|
    test "build a one-page model" {
    let model = @pagelayout.PageModel::new()
    let font = model.add_font({ family: "Carlito", bold: false, italic: false, })
    let page = @pagelayout.Page::{ width_pt: 612, height_pt: 792, items: [], }
    page.items.push(
    Text({
    font,
    size_pt: 12,
    x_pt: 72,
    baseline_pt: 82.5,
    text: "Hi",
    advances_pt: [6.5, 6.5],
    color: @pagelayout.black,
    }),
    )
    model.pages.push(page)
    inspect(model.pages.length(), content="1")
    }

    OOXML quantities stay in typed units until the layout boundary:

    ///|
    test "unit conversions" {
    inspect(@pagelayout.Twips(1440).to_pt(), content="72")
    inspect(@pagelayout.HalfPoints(24).to_pt(), content="12")
    inspect(@pagelayout.Emu(914400).to_pt(), content="72")
    inspect(@pagelayout.EighthPoints(4).to_pt(), content="0.5")
    }

    #Fonts

    Text is measured and drawn with one face per family and style, from one of three sources:

    • the bundled faces (Carlito, Liberation Sans/Serif/Mono, Noto Sans SC as the CJK fallback), embedded in a PDF as subsets;
    • a caller's own TrueType/OpenType file, FontRegistry::register in pagelayout/fonts, embedded when it has TrueType outlines;
    • a PDF standard font, FontRegistry::register_standard: one of the twelve Latin faces @fonts.standard_fonts() lists (Helvetica, Times-Roman and Courier, each with its bold, italic/oblique and bold italic face), declared by name with /WinAnsiEncoding and never embedded. Its metrics are the caller's, built with FaceMetrics::new from the font's AFM (pagelayout ships no AFM data); text outside WinAnsi is dropped, and kerning goes into the runs' advances. Symbol and ZapfDingbats are not supported.

    Hand the same FontRegistry to layout and to @pdf.RenderOptions, so that text is drawn in the face it was measured with.

    AnchorItem

    pub(all) struct AnchorItem {
    name : String
    x_pt : Double
    y_pt : Double
    } derive(Eq, ToJson,
    Debug
    )

    A named position on a page that Named(name) links and outlines jump to; (x_pt, y_pt) is the point a viewer brings to the top-left of the window. Non-visual.

    AnchorItem::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn AnchorItem::equal(AnchorItem, AnchorItem) -> Bool

    AnchorItem::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn AnchorItem::not_equal(x : AnchorItem, y : AnchorItem) -> Bool

    AnchorItem::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn AnchorItem::to_json(AnchorItem) -> Json

    AnchorItem::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn AnchorItem::to_repr(AnchorItem) ->
    Repr

    Color

    pub(all) struct Color {
    r : Int
    g : Int
    b : Int
    } derive(Eq, ToJson,
    Debug
    )

    Solid sRGB color; each channel is 0..=255 (checked by PageModel::validate, clamped on entry by Color::rgb). No alpha in v1: solid colors keep the SVG output inside svgdiff's deterministic subset and match common document text.

    Color::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Color::equal(Color, Color) -> Bool

    Color::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Color::not_equal(x : Color, y : Color) -> Bool

    Color::rgb

    fn Color::rgb(r : Int, g : Int, b : Int) -> Color

    Build a color, clamping each channel into 0..=255. Frontends convert untrusted document values through this so every encoding of the model (Eq, JSON, hex) agrees.

    Color::to_hex

    fn Color::to_hex(self : Color) -> String

    Lowercase #rrggbb, the form both the SVG emitter and tests use. Channels are formatted modulo the valid range (see Color::rgb).

    Color::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Color::to_json(Color) -> Json

    Color::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Color::to_repr(Color) ->
    Repr

    EighthPoints

    pub(all) struct EighthPoints(Int) derive(Eq, ToJson,
    Debug
    )

    Eighths of a point — OOXML's unit for border widths (w:sz on borders).

    EighthPoints::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn EighthPoints::equal(EighthPoints, EighthPoints) -> Bool

    EighthPoints::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn EighthPoints::not_equal(x : EighthPoints, y : EighthPoints) -> Bool

    EighthPoints::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn EighthPoints::to_json(EighthPoints) -> Json

    EighthPoints::to_pt

    fn EighthPoints::to_pt(self : EighthPoints) -> Double

    Convert to points (8 eighth-points per point).

    EighthPoints::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn EighthPoints::to_repr(EighthPoints) ->
    Repr

    Emu

    pub(all) struct Emu(Int) derive(Eq, ToJson,
    Debug
    )

    English Metric Units — OOXML's unit for drawing/image extents (914400 per inch).

    Emu::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Emu::equal(Emu, Emu) -> Bool

    Emu::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Emu::not_equal(x : Emu, y : Emu) -> Bool

    Emu::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Emu::to_json(Emu) -> Json

    Emu::to_pt

    fn Emu::to_pt(self : Emu) -> Double

    Convert to points (12700 EMU per point).

    Emu::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Emu::to_repr(Emu) ->
    Repr

    FillRule

    pub(all) enum FillRule {
    NonZero
    EvenOdd
    } derive(Eq, ToJson,
    Debug
    )

    Which regions of a self-intersecting path are inside.

    FillRule::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn FillRule::equal(FillRule, FillRule) -> Bool

    FillRule::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn FillRule::not_equal(x : FillRule, y : FillRule) -> Bool

    FillRule::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn FillRule::to_json(FillRule) -> Json

    FillRule::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn FillRule::to_repr(FillRule) ->
    Repr

    FontSpec

    pub(all) struct FontSpec {
    family : String
    bold : Bool
    italic : Bool
    } derive(Eq, ToJson,
    Debug
    )

    A font face a glyph run references, by index into PageModel::fonts. family is the resolved (post font-mapping) family name; bold and italic select the face within it.

    FontSpec::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn FontSpec::equal(FontSpec, FontSpec) -> Bool

    FontSpec::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn FontSpec::not_equal(x : FontSpec, y : FontSpec) -> Bool

    FontSpec::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn FontSpec::to_json(FontSpec) -> Json

    FontSpec::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn FontSpec::to_repr(FontSpec) ->
    Repr

    GlyphRun

    pub(all) struct GlyphRun {
    font : Int
    size_pt : Double
    x_pt : Double
    baseline_pt : Double
    text : String
    advances_pt : Array[Double]
    color : Color
    } derive(Eq, ToJson,
    Debug
    )

    A run of text on one baseline in one font/size/color. advances_pt[i] is the horizontal advance of the char at index i of text (UTF-16 code units; the trailing surrogate of a pair carries advance 0).

    GlyphRun::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GlyphRun::equal(GlyphRun, GlyphRun) -> Bool

    GlyphRun::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GlyphRun::not_equal(x : GlyphRun, y : GlyphRun) -> Bool

    GlyphRun::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GlyphRun::to_json(GlyphRun) -> Json

    GlyphRun::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GlyphRun::to_repr(GlyphRun) ->
    Repr

    GlyphRun::width_pt

    fn GlyphRun::width_pt(self : GlyphRun) -> Double

    Total advance of the run: where the next run on the same baseline starts.

    Gradient

    pub(all) struct Gradient {
    shape : GradientShape
    stops : Array[GradientStop]
    transform : Matrix
    } derive(Eq, ToJson,
    Debug
    )

    A gradient: its colours vary over shape, in gradient space, which transform maps to the painted path's space. Beyond its ends it keeps its end colours (SVG's pad). Stops are in ascending order of offset, the first at 0 and the last at 1. Stops at the same offset change the colour sharply there, the later one taking over at the offset itself; at offset 0 that leaves only the last of them to count, and at offset 1 only the first.

    A gradient whose shape has no extent paints its last stop's colour everywhere (see Gradient::degenerate_color).

    Any other gradient is from 0.001 to 1e12 points in size on the page (checked by PageModel::validate): a linear one's length from its start to its end; a radial one's largest radius or separation of its centres along either axis of gradient space, measured on the page along whichever axis is the longer there. Renderers draw gradients outside that range wrongly or not at all (Cairo paints nothing for one much below 1e-4 points, Poppler nothing for a linear one about 1e18 points long across a page), and the backends do not reshape them to fit. Within it, both backends write a gradient's geometry and stop offsets exactly. Renderers resolve a gradient's parameter to their own precision: Poppler's Splash draws stops 1e-8 apart on a gradient 1e9 points long, or a sharp change on one 1e12 points long, where they are; Cairo (and so librsvg) resolves the parameter to about 1/65536, so it merges or moves colour changes nearer than that fraction of a gradient's size.

    Gradient::degenerate_color

    fn Gradient::degenerate_color(self : Gradient) -> Color?

    The one colour a gradient without extent paints, its last stop's: a linear gradient whose ends coincide, a radial one whose end circle has radius 0 (both as SVG specifies), or one whose circles coincide. None for any other gradient (or one without stops). PDF's shadings leave such shapes undefined, and renderers disagree about them, so both backends paint the colour, not a shading.

    Gradient::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Gradient::equal(Gradient, Gradient) -> Bool

    Gradient::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Gradient::not_equal(x : Gradient, y : Gradient) -> Bool

    Gradient::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Gradient::to_json(Gradient) -> Json

    Gradient::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Gradient::to_repr(Gradient) ->
    Repr

    GradientShape

    pub(all) enum GradientShape {
    Linear(x1~ : Double, y1~ : Double, x2~ : Double, y2~ : Double)
    Radial(x1~ : Double, y1~ : Double, r1~ : Double, x2~ : Double, y2~ : Double, r2~ : Double)
    } derive(Eq, ToJson,
    Debug
    )

    Where a gradient's colours vary, in gradient space: offset 0 is at its start and offset 1 at its end.

    GradientShape::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GradientShape::equal(GradientShape, GradientShape) -> Bool

    GradientShape::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GradientShape::not_equal(x : GradientShape, y : GradientShape) -> Bool

    GradientShape::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GradientShape::to_json(GradientShape) -> Json

    GradientShape::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GradientShape::to_repr(GradientShape) ->
    Repr

    GradientStop

    pub(all) struct GradientStop {
    offset : Double
    color : Color
    } derive(Eq, ToJson,
    Debug
    )

    A colour at a position (0 to 1) along a gradient.

    GradientStop::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GradientStop::equal(GradientStop, GradientStop) -> Bool

    GradientStop::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GradientStop::not_equal(x : GradientStop, y : GradientStop) -> Bool

    GradientStop::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GradientStop::to_json(GradientStop) -> Json

    GradientStop::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GradientStop::to_repr(GradientStop) ->
    Repr

    GraphicItem

    pub(all) struct GraphicItem {
    x_pt : Double
    y_pt : Double
    ops : Array[GraphicOp]
    } derive(Eq, ToJson,
    Debug
    )

    A vector graphic whose space has its origin at (x_pt, y_pt) on the page. Its ops draw in painter's order. Every Save has a matching Restore, and every number is finite (checked, with the rest of the ops' requirements, by PageModel::validate).

    Every number is also within the range a PDF reader is sure to hold in a real, ±3.403e38 (PDF 32000-1, Annex C), and so are the transformations as they compose from the page and where each gradient lands on it (also checked by validate, as are the sizes on the page Gradient requires). Annex C has more limits a graphic cannot be checked against: reals nearer 0 than about 1.175e-38 read as 0, older readers keep only about five significant digits, and integers are sure only up to 2147483647 in magnitude. The PDF backend writes a graphic's numbers exactly (an integral one beyond 2147483647 with a decimal point, so that it reads as a real), leaving precision beyond five digits to the readers that keep it.

    GraphicItem::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GraphicItem::equal(GraphicItem, GraphicItem) -> Bool

    GraphicItem::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GraphicItem::not_equal(x : GraphicItem, y : GraphicItem) -> Bool

    GraphicItem::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GraphicItem::to_json(GraphicItem) -> Json

    GraphicItem::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GraphicItem::to_repr(GraphicItem) ->
    Repr

    GraphicOp

    pub(all) enum GraphicOp {
    Save
    Restore
    Transform(Matrix)
    Clip(Array[PathSegment], FillRule)
    Alpha(Double, Double)
    Path(PathItem)
    Text(GlyphRun)
    PaintedText(GlyphRun, TextPaint)
    Image(ImageItem)
    } derive(Eq, ToJson,
    Debug
    )

    One operation of a graphic, in order.

    GraphicOp::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GraphicOp::equal(GraphicOp, GraphicOp) -> Bool

    GraphicOp::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GraphicOp::not_equal(x : GraphicOp, y : GraphicOp) -> Bool

    GraphicOp::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GraphicOp::to_json(GraphicOp) -> Json

    GraphicOp::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn GraphicOp::to_repr(GraphicOp) ->
    Repr

    HalfPoints

    pub(all) struct HalfPoints(Int) derive(Eq, ToJson,
    Debug
    )

    Half-points — OOXML's unit for font sizes (w:sz).

    HalfPoints::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn HalfPoints::equal(HalfPoints, HalfPoints) -> Bool

    HalfPoints::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn HalfPoints::not_equal(x : HalfPoints, y : HalfPoints) -> Bool

    HalfPoints::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn HalfPoints::to_json(HalfPoints) -> Json

    HalfPoints::to_pt

    fn HalfPoints::to_pt(self : HalfPoints) -> Double

    Convert to points (2 half-points per point).

    HalfPoints::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn HalfPoints::to_repr(HalfPoints) ->
    Repr

    ImageItem

    pub(all) struct ImageItem {
    x_pt : Double
    y_pt : Double
    w_pt : Double
    h_pt : Double
    data : Bytes
    mime : String
    } derive(Eq, ToJson,
    Debug
    )

    A placed raster image; data is the encoded file, not pixels.

    ImageItem::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn ImageItem::equal(ImageItem, ImageItem) -> Bool

    ImageItem::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn ImageItem::not_equal(x : ImageItem, y : ImageItem) -> Bool

    ImageItem::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn ImageItem::to_json(ImageItem) -> Json

    ImageItem::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn ImageItem::to_repr(ImageItem) ->
    Repr

    LineCap

    pub(all) enum LineCap {
    ButtCap
    RoundCap
    SquareCap
    } derive(Eq, ToJson,
    Debug
    )

    How the ends of an open stroked subpath are drawn.

    LineCap::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn LineCap::equal(LineCap, LineCap) -> Bool

    LineCap::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn LineCap::not_equal(x : LineCap, y : LineCap) -> Bool

    LineCap::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn LineCap::to_json(LineCap) -> Json

    LineCap::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn LineCap::to_repr(LineCap) ->
    Repr

    LineJoin

    pub(all) enum LineJoin {
    MiterJoin
    RoundJoin
    BevelJoin
    } derive(Eq, ToJson,
    Debug
    )

    How the corners of a stroked path are drawn.

    LineJoin::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn LineJoin::equal(LineJoin, LineJoin) -> Bool

    LineJoin::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn LineJoin::not_equal(x : LineJoin, y : LineJoin) -> Bool

    LineJoin::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn LineJoin::to_json(LineJoin) -> Json

    LineJoin::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn LineJoin::to_repr(LineJoin) ->
    Repr

    LinkRegion

    pub(all) struct LinkRegion {
    x_pt : Double
    y_pt : Double
    w_pt : Double
    h_pt : Double
    target : LinkTarget
    } derive(Eq, ToJson,
    Debug
    )

    An interactive region (hyperlink); geometry only, painted by nothing. LinkTarget::parse reads a link string the way target was read when it was one.

    LinkRegion::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn LinkRegion::equal(LinkRegion, LinkRegion) -> Bool

    LinkRegion::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn LinkRegion::not_equal(x : LinkRegion, y : LinkRegion) -> Bool

    LinkRegion::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn LinkRegion::to_json(LinkRegion) -> Json

    LinkRegion::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn LinkRegion::to_repr(LinkRegion) ->
    Repr

    LinkTarget

    pub(all) enum LinkTarget {
    Named(String)
    Uri(String)
    } derive(Eq, ToJson,
    Debug
    )

    Where a LinkRegion leads.

    LinkTarget::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn LinkTarget::equal(LinkTarget, LinkTarget) -> Bool

    LinkTarget::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn LinkTarget::not_equal(x : LinkTarget, y : LinkTarget) -> Bool

    LinkTarget::parse

    fn LinkTarget::parse(target : String) -> LinkTarget

    The target a link string names by the convention LinkRegion targets were strings under: #name is the anchor name, anything else a URI.

    LinkTarget::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn LinkTarget::to_json(LinkTarget) -> Json

    LinkTarget::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn LinkTarget::to_repr(LinkTarget) ->
    Repr

    Matrix

    pub(all) struct Matrix {
    a : Double
    b : Double
    c : Double
    d : Double
    e : Double
    f : Double
    } derive(Eq, ToJson,
    Debug
    )

    An affine transformation [a b c d e f], mapping (x, y) to (a*x + c*y + e, b*x + d*y + f) (PDF's and SVG's convention).

    Matrix::after

    fn Matrix::after(self : Matrix, other : Matrix) -> Matrix

    self applied after other: the transformation that maps a point through other first, then through self.

    Matrix::apply

    fn Matrix::apply(self : Matrix, x : Double, y : Double) -> (Double, Double)

    Map a point.

    Matrix::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Matrix::equal(Matrix, Matrix) -> Bool

    Matrix::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Matrix::not_equal(x : Matrix, y : Matrix) -> Bool

    Matrix::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Matrix::to_json(Matrix) -> Json

    Matrix::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Matrix::to_repr(Matrix) ->
    Repr

    Page

    pub(all) struct Page {
    width_pt : Double
    height_pt : Double
    items : Array[PageItem]
    } derive(Eq, ToJson,
    Debug
    )

    A single laid-out page: physical size plus its positioned items.

    Page::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Page::equal(Page, Page) -> Bool

    Page::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Page::not_equal(x : Page, y : Page) -> Bool

    Page::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Page::to_json(Page) -> Json

    Page::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Page::to_repr(Page) ->
    Repr

    PageItem

    pub(all) enum PageItem {
    Text(GlyphRun)
    Rect(RectItem)
    Image(ImageItem)
    Link(LinkRegion)
    Anchor(AnchorItem)
    Graphic(GraphicItem)
    } derive(Eq, ToJson,
    Debug
    )

    One positioned item on a page, in painter's order.

    PageItem::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PageItem::equal(PageItem, PageItem) -> Bool

    PageItem::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PageItem::not_equal(x : PageItem, y : PageItem) -> Bool

    PageItem::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PageItem::to_json(PageItem) -> Json

    PageItem::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PageItem::to_repr(PageItem) ->
    Repr

    PageModel

    pub(all) struct PageModel {
    fonts : Array[FontSpec]
    pages : Array[Page]
    } derive(Eq, ToJson,
    Debug
    )

    The layout engine's complete output: interned fonts plus pages.

    PageModel::add_font

    fn PageModel::add_font(self : PageModel, spec : FontSpec) -> Int

    Intern spec, returning its index for GlyphRun::font.

    PageModel::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PageModel::equal(PageModel, PageModel) -> Bool

    PageModel::new

    fn PageModel::new() -> PageModel

    An empty model to accumulate fonts and pages into.

    PageModel::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PageModel::not_equal(x : PageModel, y : PageModel) -> Bool

    PageModel::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PageModel::to_json(PageModel) -> Json

    PageModel::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PageModel::to_repr(PageModel) ->
    Repr

    PageModel::validate

    fn PageModel::validate(self : PageModel) -> Array[String]

    Check every structural invariant; return one human-readable message per violation (empty means the model is well-formed):

    • every GlyphRun has exactly one advance per UTF-16 code unit of its text, a non-negative size, and a font index into fonts;
    • every RectItem has non-negative extents, and its stroke and stroke_w_pt agree (both present or both absent);
    • every color channel is within 0..=255;
    • every page has positive extents.

    Paint

    pub(all) enum Paint {
    Solid(Color)
    GradientPaint(Gradient)
    } derive(Eq, ToJson,
    Debug
    )

    What fills or strokes a path.

    Paint::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Paint::equal(Paint, Paint) -> Bool

    Paint::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Paint::not_equal(x : Paint, y : Paint) -> Bool

    Paint::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Paint::to_json(Paint) -> Json

    Paint::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Paint::to_repr(Paint) ->
    Repr

    PathItem

    pub(all) struct PathItem {
    segments : Array[PathSegment]
    fill : Paint?
    fill_rule : FillRule
    stroke : Paint?
    stroke_style : StrokeStyle
    } derive(Eq, ToJson,
    Debug
    )

    A path painted with an optional fill (by fill_rule) and an optional stroke (in stroke_style); the fill goes first. A path with neither paints nothing.

    PathItem::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PathItem::equal(PathItem, PathItem) -> Bool

    PathItem::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PathItem::not_equal(x : PathItem, y : PathItem) -> Bool

    PathItem::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PathItem::to_json(PathItem) -> Json

    PathItem::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PathItem::to_repr(PathItem) ->
    Repr

    PathSegment

    pub(all) enum PathSegment {
    MoveTo(Double, Double)
    LineTo(Double, Double)
    CurveTo(Double, Double, Double, Double, Double, Double)
    Rectangle(Double, Double, Double, Double)
    Close
    } derive(Eq, ToJson,
    Debug
    )

    One segment of a path. A path is a sequence of subpaths, each starting with MoveTo or Rectangle; LineTo, CurveTo and Close continue from the current point, so they need one before them (checked by PageModel::validate). Close joins a subpath's end to its start, which becomes the current point.

    PathSegment::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PathSegment::equal(PathSegment, PathSegment) -> Bool

    PathSegment::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PathSegment::not_equal(x : PathSegment, y : PathSegment) -> Bool

    PathSegment::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PathSegment::to_json(PathSegment) -> Json

    PathSegment::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn PathSegment::to_repr(PathSegment) ->
    Repr

    RectItem

    pub(all) struct RectItem {
    x_pt : Double
    y_pt : Double
    w_pt : Double
    h_pt : Double
    fill : Color?
    stroke : Color?
    stroke_w_pt : Double
    } derive(Eq, ToJson,
    Debug
    )

    Axis-aligned filled and/or stroked rectangle. Doubles as underlines, table borders, and shading (thin or filled).

    RectItem::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn RectItem::equal(RectItem, RectItem) -> Bool

    RectItem::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn RectItem::not_equal(x : RectItem, y : RectItem) -> Bool

    RectItem::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn RectItem::to_json(RectItem) -> Json

    RectItem::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn RectItem::to_repr(RectItem) ->
    Repr

    StrokeStyle

    pub(all) struct StrokeStyle {
    width : StrokeWidth
    cap : LineCap
    join : LineJoin
    miter_limit : Double
    dash : Array[Double]
    dash_phase : Double
    } derive(Eq, ToJson,
    Debug
    )

    How a path is stroked. dash is the dash pattern (lengths of dashes and gaps, alternately, at least one of them positive; empty for a solid line) starting dash_phase into it. The miter limit is at least 1.

    StrokeStyle::default

    fn StrokeStyle::default() -> StrokeStyle

    A solid line one point wide with butt caps and miter joins (limit 10), the initial stroke state of PDF.

    StrokeStyle::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn StrokeStyle::equal(StrokeStyle, StrokeStyle) -> Bool

    StrokeStyle::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn StrokeStyle::not_equal(x : StrokeStyle, y : StrokeStyle) -> Bool

    StrokeStyle::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn StrokeStyle::to_json(StrokeStyle) -> Json

    StrokeStyle::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn StrokeStyle::to_repr(StrokeStyle) ->
    Repr

    StrokeWidth

    pub(all) enum StrokeWidth {
    Width(Double)
    Hairline
    } derive(Eq, ToJson,
    Debug
    )

    How wide a stroke is. PDF and SVG disagree about a width of 0 (the thinnest line a device can draw in PDF, nothing at all in SVG), so a Width must be positive (checked by PageModel::validate) and the thinnest line is asked for explicitly.

    StrokeWidth::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn StrokeWidth::equal(StrokeWidth, StrokeWidth) -> Bool

    StrokeWidth::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn StrokeWidth::not_equal(x : StrokeWidth, y : StrokeWidth) -> Bool

    StrokeWidth::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn StrokeWidth::to_json(StrokeWidth) -> Json

    StrokeWidth::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn StrokeWidth::to_repr(StrokeWidth) ->
    Repr

    TextPaint

    pub(all) struct TextPaint {
    fill : Bool
    stroke : Color?
    stroke_style : StrokeStyle
    } derive(Eq, ToJson,
    Debug
    )

    How PaintedText paints its glyphs (PDF's text rendering modes): filled in the run's colour or not, and outlined in stroke or not. An outline is stroked in stroke_style as a path would be, wholly: nothing of the stroke style of the paths before it carries over. A run neither filled nor stroked is invisible but still text (it extracts and searches).

    TextPaint::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn TextPaint::equal(TextPaint, TextPaint) -> Bool

    TextPaint::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn TextPaint::not_equal(x : TextPaint, y : TextPaint) -> Bool

    TextPaint::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn TextPaint::to_json(TextPaint) -> Json

    TextPaint::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn TextPaint::to_repr(TextPaint) ->
    Repr

    Twips

    pub(all) struct Twips(Int) derive(Eq, ToJson,
    Debug
    )

    Twentieths of a point — OOXML's unit for indents, spacing, margins, page sizes (w:twip).

    Twips::equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Twips::equal(Twips, Twips) -> Bool

    Twips::not_equal

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Twips::not_equal(x : Twips, y : Twips) -> Bool

    Twips::to_json

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Twips::to_json(Twips) -> Json

    Twips::to_pt

    fn Twips::to_pt(self : Twips) -> Double

    Convert to points (20 twips per point).

    Twips::to_repr

    #deprecated("implicit trait-method promotion is being removed; call via the trait")
    fn Twips::to_repr(Twips) ->
    Repr

    black

    let black : Color

    Default document text color.

    identity

    let identity : Matrix

    The identity transformation.