Toddy.Iced.Font (Toddy v0.3.0)

Copy Markdown View Source

Font descriptor for the text widget font prop and Settings default_font.

Maps to iced's Font struct. Accepts :default, :monospace, a family name string, or a map with :family, :weight, :style, and :stretch.

Summary

Functions

Encodes a font value to the wire format.

Types

font_map()

@type font_map() :: %{
  optional(:family) => String.t(),
  optional(:weight) => weight(),
  optional(:style) => style(),
  optional(:stretch) => stretch()
}

stretch()

@type stretch() ::
  :ultra_expanded
  | :extra_expanded
  | :expanded
  | :semi_expanded
  | :normal
  | :semi_condensed
  | :condensed
  | :extra_condensed
  | :ultra_condensed

style()

@type style() :: :oblique | :italic | :normal

t()

@type t() :: :default | :monospace | String.t() | font_map()

weight()

@type weight() ::
  :black
  | :extra_bold
  | :bold
  | :semi_bold
  | :medium
  | :normal
  | :light
  | :extra_light
  | :thin

Functions

encode(name)

@spec encode(font :: t()) :: String.t() | map()

Encodes a font value to the wire format.

Examples

iex> Toddy.Iced.Font.encode(:default)
"default"

iex> Toddy.Iced.Font.encode(:monospace)
"monospace"

iex> Toddy.Iced.Font.encode("Fira Code")
%{"family" => "Fira Code"}

iex> Toddy.Iced.Font.encode(%{family: "Inter", weight: :bold, style: :italic})
%{"family" => "Inter", "weight" => "Bold", "style" => "Italic"}