Layout
Backend-neutral layout values for Spectra.
These constructors describe intent. They deliberately contain no measured coordinates or Typst-specific layout state; a Pict is plain data a backend interprets later, which is why building one needs no effects and shows as the constructors it is made of:
fn main() = println(show(column(8, [text("hi")])))
Layout.Column(8, Layout.Left, [Layout.Text(Layout.TextStyle { size = 0, color = "", align = Layout.Left }, [Layout.Plain("hi")])])
Types
Align
type Align = Left | Center | Right deriving (Eq, Show)
FitMode
type FitMode = Contain | Cover deriving (Eq, Show)
Inline
type Inline
= Plain(String)
| Emphasis(List(Inline))
| Strong(List(Inline))
| InlineCode(String)
| Link(String, List(Inline))
| Colored(String, List(Inline))
deriving (Eq, Show)
TextStyle
type TextStyle = TextStyle {
size: Int,
color: String,
align: Align
} deriving (Eq, Show)
Pict
type Pict
= Empty
| Text(TextStyle, List(Inline))
| CodeBlock(String, String)
| Image(String)
| Rectangle(String, Int, Int)
| Row(Int, List(Pict))
| Column(Int, Align, List(Pict))
| Overlay(List(Pict))
| Inset(Int, Int, Int, Int, Pict)
| Fit(FitMode, Pict)
| Fragment(Int, Pict)
| RawTypst(String)
deriving (Eq, Show)
Functions and Values
text
text : (String) -> Pict
Normal body text in the theme foreground. A size of zero means “theme body size” to the renderer.
rich_text
rich_text : (List(Inline)) -> Pict
Rich inline text in the theme foreground.
para
para : (List(Inline)) -> Pict
A paragraph-sized inline sequence. This is an authoring synonym for rich_text, retained because it reads naturally inside a slide builder.
item_text
item_text : (List(Inline)) -> Pict
A bullet item rendered as an accent arrow and rich inline text.
item
item : (String) -> Pict
A plain bullet item.
row
row : (Int, List(Pict)) -> Pict
column
column : (Int, List(Pict)) -> Pict
centered
centered : (Int, List(Pict)) -> Pict
overlay
overlay : (List(Pict)) -> Pict
inset
inset : (Int, Pict) -> Pict
raw_typst
raw_typst : (String) -> Pict