# `RasterExRatatui.Font.Art`
[🔗](https://github.com/mcass19/raster_ex_ratatui/blob/v0.4.0/lib/raster_ex_ratatui/font/art.ex#L1)

ASCII art to glyph bitmaps and back, for hand-drawn fonts.

Glyphs are drawn with `#` for ink and `.` for background, one line per pixel row. `parse/3` turns the art into the bitstring layout `RasterExRatatui.Font` expects; call it from module attributes so the work happens at compile time.

A glyph may be drawn smaller than the cell and padded with background on the right and at the bottom, which is how text glyphs get their inter-cell and inter-line spacing without drawing it every time.

# `parse`

```elixir
@spec parse(String.t(), {pos_integer(), pos_integer()}, keyword()) :: bitstring()
```

Parses `art` into a `{width, height}` glyph bitstring.

## Options

  * `:pad` — `{right, bottom}` background columns and rows added around the art (default `{0, 0}`). The art must then be exactly `width - right` columns by `height - bottom` rows.

Raises `ArgumentError` when the art does not have that shape or uses a character other than `#` and `.`.

## Examples

    iex> RasterExRatatui.Font.Art.parse("#.\n.#\n", {2, 2})
    <<0b1001::4>>

    iex> RasterExRatatui.Font.Art.parse("#\n", {2, 2}, pad: {1, 1})
    <<0b1000::4>>

# `render`

```elixir
@spec render(bitstring(), {pos_integer(), pos_integer()}) :: String.t()
```

Renders a `{width, height}` glyph bitstring back to ASCII art, one line per row. Handy when debugging a font or a failing glyph assertion.

## Examples

    iex> RasterExRatatui.Font.Art.render(<<0b1001::4>>, {2, 2})
    "#.\n.#\n"

---

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