Mead.Style (mead_pdf v0.1.0)

Copy Markdown View Source

Visual and layout styling for a node.

Lengths are in PDF points. Colors are {r, g, b} tuples of 0-255 integers.

Text properties (color, font_size, line_height, font_family, font_weight, italic, text_align) are inheritable: nil means "inherit from the parent", with document defaults of black 14pt/1.2 regular in the default family at the root.

orphans/widows (also inheritable, default 2 like CSS) set the minimum number of text lines kept before / carried after a page break inside a text node; a paragraph that cannot satisfy them moves to the next page. At the top of a page an unsatisfiable rule breaks geometrically instead (progress is never sacrificed). 1 disables the constraint.

Summary

Types

A length in points, or {:percent, n} with CSS-style n (50 = 50%).

Uniform, or per-side in CSS order {top, right, bottom, left}.

t()

Types

alignment()

@type alignment() :: :start | :end | :center | :stretch | :baseline

color()

@type color() :: {0..255, 0..255, 0..255}

dimension()

@type dimension() :: number() | {:percent, number()}

A length in points, or {:percent, n} with CSS-style n (50 = 50%).

justify()

@type justify() ::
  :start | :end | :center | :space_between | :space_around | :space_evenly

sides()

@type sides() :: number() | {number(), number(), number(), number()}

Uniform, or per-side in CSS order {top, right, bottom, left}.

t()

@type t() :: %Mead.Style{
  align_items: alignment() | nil,
  align_self: alignment() | nil,
  background: color() | nil,
  border: sides(),
  border_color: color() | nil,
  border_radius: number(),
  color: color() | nil,
  flex_basis: number() | nil,
  flex_direction: :row | :column,
  flex_grow: number() | nil,
  flex_shrink: number() | nil,
  font_family: String.t() | nil,
  font_size: number() | nil,
  font_weight: number() | :normal | :bold | nil,
  gap: number(),
  height: dimension() | nil,
  italic: boolean() | nil,
  justify_content: justify() | nil,
  line_height: number() | nil,
  margin: sides(),
  max_height: dimension() | nil,
  max_width: dimension() | nil,
  min_height: dimension() | nil,
  min_width: dimension() | nil,
  orphans: pos_integer() | nil,
  padding: sides(),
  text_align: :left | :center | :right | :justify | nil,
  widows: non_neg_integer() | nil,
  width: dimension() | nil
}