# `Plushie.Type.Font`
[🔗](https://github.com/plushie-ui/plushie-elixir/blob/v0.7.2/lib/plushie/type/font.ex#L1)

Font specification with family, weight, style, and stretch.

Maps to iced's `Font` struct. Accepts `:default`, `:monospace`, a family
name string, or a `%Font{}` struct with detailed font properties.

# `stretch`

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

# `style`

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

# `t`

```elixir
@type t() ::
  :default
  | :monospace
  | String.t()
  | %Plushie.Type.Font{
      family: String.t() | nil,
      stretch: stretch() | nil,
      style: style() | nil,
      weight: weight() | nil
    }
```

# `weight`

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

# `cast`

```elixir
@spec cast(term()) :: {:ok, t()} | :error
```

Validates a font value.

Accepts `:default`, `:monospace`, a family name string, or a
`%Font{}` struct.

## Examples

    iex> Plushie.Type.Font.cast(:default)
    {:ok, :default}

    iex> Plushie.Type.Font.cast(:monospace)
    {:ok, :monospace}

    iex> Plushie.Type.Font.cast("Fira Code")
    {:ok, "Fira Code"}

    iex> Plushie.Type.Font.cast(%Plushie.Type.Font{family: "Inter"})
    {:ok, %Plushie.Type.Font{family: "Inter"}}

    iex> Plushie.Type.Font.cast(42)
    :error

# `encode`

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

Encodes a font value to the wire format.

## Examples

    iex> Plushie.Type.Font.encode(:default)
    "default"

    iex> Plushie.Type.Font.encode(:monospace)
    "monospace"

    iex> Plushie.Type.Font.encode("Fira Code")
    %{family: "Fira Code"}

    iex> Plushie.Type.Font.encode(%{family: "Inter", weight: :bold, style: :italic})
    %{family: "Inter", weight: "bold", style: "italic"}

# `from_opts`

```elixir
@spec from_opts(Keyword.t()) :: %Plushie.Type.Font{
  family: term(),
  stretch: term(),
  style: term(),
  weight: term()
}
```

Constructs a font from a keyword list.

Raises `ArgumentError` if any key is not a valid font field.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
