Paginated document layout engine: format-neutral page-model IR with SVG/PDF backends.
Dependencies
///|
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")
}///|
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")
}#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn AnchorItem::equal(AnchorItem, AnchorItem) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn AnchorItem::not_equal(x : AnchorItem, y : AnchorItem) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn AnchorItem::to_json(AnchorItem) -> Json#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn AnchorItem::to_repr(AnchorItem) -> Repr#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn EighthPoints::equal(EighthPoints, EighthPoints) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn EighthPoints::not_equal(x : EighthPoints, y : EighthPoints) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn EighthPoints::to_json(EighthPoints) -> Json#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn EighthPoints::to_repr(EighthPoints) -> Reprpub(all) struct Gradient {
shape : GradientShape
stops : Array[GradientStop]
transform : Matrix
} derive(Eq, ToJson, Debug)#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn GradientShape::equal(GradientShape, GradientShape) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn GradientShape::not_equal(x : GradientShape, y : GradientShape) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn GradientShape::to_json(GradientShape) -> Json#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn GradientShape::to_repr(GradientShape) -> Repr#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn GradientStop::equal(GradientStop, GradientStop) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn GradientStop::not_equal(x : GradientStop, y : GradientStop) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn GradientStop::to_json(GradientStop) -> Json#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn GradientStop::to_repr(GradientStop) -> Repr#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn GraphicItem::equal(GraphicItem, GraphicItem) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn GraphicItem::not_equal(x : GraphicItem, y : GraphicItem) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn GraphicItem::to_json(GraphicItem) -> Json#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn GraphicItem::to_repr(GraphicItem) -> Repr#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn HalfPoints::equal(HalfPoints, HalfPoints) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn HalfPoints::not_equal(x : HalfPoints, y : HalfPoints) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn HalfPoints::to_json(HalfPoints) -> Json#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn HalfPoints::to_repr(HalfPoints) -> Reprpub(all) struct LinkRegion {
x_pt : Double
y_pt : Double
w_pt : Double
h_pt : Double
target : LinkTarget
} derive(Eq, ToJson, Debug)#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn LinkRegion::equal(LinkRegion, LinkRegion) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn LinkRegion::not_equal(x : LinkRegion, y : LinkRegion) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn LinkRegion::to_json(LinkRegion) -> Json#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn LinkRegion::to_repr(LinkRegion) -> Repr#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn LinkTarget::equal(LinkTarget, LinkTarget) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn LinkTarget::not_equal(x : LinkTarget, y : LinkTarget) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn LinkTarget::to_json(LinkTarget) -> Json#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn LinkTarget::to_repr(LinkTarget) -> Reprpub(all) enum PageItem {
Text(GlyphRun)
Rect(RectItem)
Image(ImageItem)
Link(LinkRegion)
Anchor(AnchorItem)
Graphic(GraphicItem)
} derive(Eq, ToJson, Debug)pub(all) struct PathItem {
segments : Array[PathSegment]
fill : Paint?
fill_rule : FillRule
stroke : Paint?
stroke_style : StrokeStyle
} derive(Eq, ToJson, Debug)#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PathSegment::equal(PathSegment, PathSegment) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PathSegment::not_equal(x : PathSegment, y : PathSegment) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PathSegment::to_json(PathSegment) -> Json#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn PathSegment::to_repr(PathSegment) -> Repr#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn StrokeStyle::equal(StrokeStyle, StrokeStyle) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn StrokeStyle::not_equal(x : StrokeStyle, y : StrokeStyle) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn StrokeStyle::to_json(StrokeStyle) -> Json#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn StrokeStyle::to_repr(StrokeStyle) -> Repr#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn StrokeWidth::equal(StrokeWidth, StrokeWidth) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn StrokeWidth::not_equal(x : StrokeWidth, y : StrokeWidth) -> Bool#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn StrokeWidth::to_json(StrokeWidth) -> Json#deprecated("implicit trait-method promotion is being removed; call via the trait")
fn StrokeWidth::to_repr(StrokeWidth) -> Reprpub(all) struct TextPaint {
fill : Bool
stroke : Color?
stroke_style : StrokeStyle
} derive(Eq, ToJson, Debug)Install
Download zipPaginated document layout engine: format-neutral page-model IR with SVG/PDF backends.
Dependencies