Prawn's layout behaviour for MoonBit on moonbitlang/pagelayout: the document cursor and bounds, formatted text, font metrics, prawn-svg and prawn-table sizing
Dependencies
| package | what it is |
|---|---|
| bobzhang/prawn | the document cursor, bounds, columns and pages (Flow), formatted text (Fragment, Style) and its line wrapping (typeset_lines, Flow::typeset, Flow::typeset_box), font metrics of TrueType and the standard AFM fonts (FontCatalog, Face) with fallback fonts and icon fonts; and Document, Prawn's own API as far as it is ported (pages, the cursor and bounding boxes, text and text boxes, fonts, images, graphics) |
| bobzhang/prawn/svg | a port of prawn-svg 0.34.2: SVG documents rendered into pagelayout graphic operations |
| bobzhang/prawn/table | prawn-table 0.2.2's sizing: column widths and row heights |
let catalog = FontCatalog::load(files)
let flow = Flow::new(catalog, setup, hooks={ ..Hooks::new(), base_family: "Noto Serif" })
flow.start_new_page()
flow.typeset(fragments, line_metrics(1.15, flow.font(style), style.size), style)pub(all) suberror PrawnError {
CannotFit
IncompatibleStringEncoding(String)
ArgumentError(String)
UnknownFont(String)
BadFontFamily(String)
EmptyGraphicStateStack
UnsupportedImageType(String)
Unsupported(String)
}pub(all) struct Bounds {
left : Double
bottom : Double
width : Double
height : Double
absolute_left : Double
absolute_top : Double
}pub(all) struct Columns {
count : Int
stride : Double
current : Int
}pub struct Document {
family : String
size : Double
// private fields
}fn Document::dash(self : Document, lengths : Array[Double], space? : Double, phase? : Double) -> Unit raise PrawnErrorfn Document::formatted_text(self : Document, fragments : Array[TextFragment], size? : Double, style? : FontStyle, align? : Alignment, leading? : Double, draw_text_callback? : (String, (Double, Double), Bool) -> Unit raise PrawnError) -> Unit raise PrawnErrorfn Document::height_of(self : Document, string : String, size? : Double, style? : FontStyle, width? : Double, leading? : Double) -> Double raise PrawnErrorfn Document::image(self : Document, file : String, at? : (Double, Double), width? : Double, height? : Double, scale? : Double, fit? : (Double, Double), position? : ImagePosition, vposition? : ImageVPosition) -> ImageInfo raise PrawnErrorfn Document::span(self : Document, width : Double, position? : SpanPosition, body : () -> Unit raise) -> Unit raisefn Document::text(self : Document, string : String, size? : Double, style? : FontStyle, align? : Alignment, leading? : Double, inline_format? : Bool, draw_text_callback? : (String, (Double, Double), Bool) -> Unit raise PrawnError) -> Unit raise PrawnErrorfn Document::text_box(self : Document, string : String, at? : (Double, Double), width? : Double, height? : Double, size? : Double, style? : FontStyle, align? : Alignment, valign? : VerticalAlignment, overflow? : Overflow, min_font_size? : Double, leading? : Double, rotate? : Double, rotate_around? : String, draw_text_callback? : (String, (Double, Double), Bool) -> Unit raise PrawnError) -> String raisefn Document::width_of(self : Document, string : String, size? : Double, style? : FontStyle, kerning? : Bool) -> Double raise PrawnErrorpub(all) struct Face {
metrics : FaceMetrics
ascender : Int
descender : Int
line_gap : Int
kern : Map[Int, Double]
standard : Bool
}pub(all) struct Flow {
catalog : FontCatalog
setup : PageSetup
hooks : Hooks
model : PageModel
scratch : Bool
page_top : Double
top : Double
bottom : Double
page : Int
y : Double
left : Double
right : Double
columns : Columns?
last_line : (Line, Int, Double)?
last_line_first : Bool
taring : Int
inked : Bool
first_break_empty : Bool?
page_margins : (Int) -> (Double, Double)?
margin_left : Double
margin_right : Double
page_width_now : Double
page_height_now : Double
}pub struct FontCatalog {
faces : Map[String, Face]
registry : FontRegistry
legacy_icons : Map[String, String]
// private fields
}fn FontCatalog::load(files : Array[(String, Bool, Bool, Bytes)], icon_sets? : Array[IconSet], legacy_icon_mapping? : String, fallbacks? : Array[String]) -> FontCatalog raisepub(all) enum FontStyle {
Normal
Bold
Italic
BoldItalic
}pub(all) struct FragmentCallback {
render_behind : (PlacedFragment) -> Unit raise PrawnError?
render_in_front : (PlacedFragment) -> Unit raise PrawnError?
}pub(all) struct IconSet {
name : String
font : Bytes
legend : String
}pub(all) struct ImageInfo {
kind : String
width : Int
height : Int
}pub(all) enum ImagePosition {
ImageLeft
ImageCenter
ImageRight
ImageAt(Double)
}pub(all) enum ImageVPosition {
ImageTop
ImageMiddle
ImageBottom
ImageDown(Double)
}pub(all) struct Item {
unit : Int
fragment : Int
fit : Double
draw : Double
kern : Double
hard_break : Bool
anchor : String?
offset : Int
}pub(all) struct Line {
runs : Array[LineRun]
anchors : Array[(String, Double)]
fit_width : Double
ascender : Double
descender : Double
height : Double
empty_links : Array[(Double, Style, Face)]
images : Array[(Double, Int, Double, Double, Bool, Style, Face)]
marks : Array[(Double, Style, Face)]
held : Array[(Int, Double, Style, Face)]
}pub(all) struct LineMetrics {
leading : Double
padding_top : Double
padding_bottom : Double
}pub(all) struct Mark {
page : Int
y : Double
item : Int
}pub(all) enum Overflow {
Truncate
ShrinkToFit
Expand
}pub(all) struct PageSetup {
width : Double
height : Double
margin_top : Double
margin_right : Double
margin_bottom : Double
margin_left : Double
}pub(all) struct PlacedFragment {
text : String
left : Double
baseline : Double
width : Double
height : Double
top : Double
bottom : Double
}pub(all) enum SpanPosition {
SpanLeft
SpanCenter
SpanRight
SpanAt(Double)
}pub(all) struct Style {
family : String
size : Double
bold : Bool
italic : Bool
color : Color
link : LinkTarget?
background : Color?
script : Int
border_offset : Double
underline : Bool
strike : Bool
wj : Bool
image : Int
callback : Int
doc_bold : Bool
doc_italic : Bool
font_set : Bool
text_transform : String?
code_background : CodeBackground?
linenum : Bool
line_mark : Bool
wrap_break : Bool
} derive(Eq)pub(all) struct TextFragment {
text : String
bold : Bool
italic : Bool
underline : Bool
strikethrough : Bool
subscript : Bool
superscript : Bool
font : String?
size : Double?
color : String?
cmyk : Array[Double]?
character_spacing : Double?
link : String?
anchor : String?
callbacks : Array[FragmentCallback]
}pub(all) enum VerticalAlignment {
Top
Center
Bottom
}fn page_size_named(name : String) -> (Double, Double)?fn pdf_anchor_name(id : String) -> Stringfn ruby_number(x : Double) -> StringInstall
Download zipPrawn's layout behaviour for MoonBit on moonbitlang/pagelayout: the document cursor and bounds, formatted text, font metrics, prawn-svg and prawn-table sizing
Dependencies