RasterExRatatui.Font.Default6x8 (RasterExRatatui v0.4.0)

Copy Markdown View Source

The built-in 6×8 monospace bitmap font, drawn for a 400×300 1-bit e-ink panel and readable on any panel with an integer scale:.

Each cell is 6×8 pixels: text glyphs are drawn 5×7 with one blank column on the right (inter-cell spacing) and one blank row at the bottom (inter-line spacing); box-drawing and block glyphs fill all 48 pixels so they join across cells.

Coverage

Hand-drawn:

  • All of printable ASCII (U+0020–U+007E)
  • Light box drawing ─ │ ┌ ┐ └ ┘ ├ ┤ ┬ ┴ ┼, and the corners and lines of every Block border type: rounded ╭ ╮ ╰ ╯, heavy ━ ┃ ┏ ┓ ┗ ┛, double ═ ║ ╔ ╗ ╚ ╝
  • Block elements: █ ▀ ▄ ░ ▒ ▓
  • Symbols: ° · • … ← ↑ → ↓ ✓ ✗ ▲ ▶ ▼ ◀ ○ ●

Generated from their Unicode geometry by RasterExRatatui.Font.Generated:

  • The braille block U+2800–U+28FF (the Canvas widget's default marker); each dot is a solid 3×2 block, so neighbouring dots merge into lines
  • Eighth blocks ▁ ▂ ▃ ▅ ▆ ▇, ▏ ▎ ▍ ▌ ▋ ▊ ▉, ▐ ▔ ▕
  • Quadrants ▖ ▗ ▘ ▙ ▚ ▛ ▜ ▝ ▞ ▟ (BigText's :quadrant size)

Hand-drawn glyphs win where both exist. Any other codepoint renders as a hatched box (RasterExRatatui.Font.Generated.hatched/1), so it is obvious in a rendering rather than silently blank.

Examples

iex> alias RasterExRatatui.Font.{Art, Default6x8}
iex> Default6x8.glyph(?A) |> Art.render(Default6x8.cell_size())
".###..\n#...#.\n#...#.\n#####.\n#...#.\n#...#.\n#...#.\n......\n"

Summary

Functions

Cell size in pixels: {6, 8}.

Every codepoint with a glyph, sorted ascending. For tests and tooling.

The 48-bit bitmap for codepoint, or the hatched placeholder.

Whether codepoint has a hand-drawn or generated glyph.

Functions

cell_size()

@spec cell_size() :: {6, 8}

Cell size in pixels: {6, 8}.

Examples

iex> RasterExRatatui.Font.Default6x8.cell_size()
{6, 8}

codepoints()

@spec codepoints() :: [non_neg_integer()]

Every codepoint with a glyph, sorted ascending. For tests and tooling.

Examples

iex> ?A in RasterExRatatui.Font.Default6x8.codepoints()
true

glyph(codepoint)

@spec glyph(non_neg_integer()) :: <<_::48>>

The 48-bit bitmap for codepoint, or the hatched placeholder.

Examples

iex> RasterExRatatui.Font.Default6x8.glyph(?\s)
<<0::48>>

iex> RasterExRatatui.Font.Default6x8.glyph(0x1F600) == RasterExRatatui.Font.Generated.hatched({6, 8})
true

has_glyph?(codepoint)

@spec has_glyph?(non_neg_integer()) :: boolean()

Whether codepoint has a hand-drawn or generated glyph.

Examples

iex> RasterExRatatui.Font.Default6x8.has_glyph?(0x2588)
true

iex> RasterExRatatui.Font.Default6x8.has_glyph?(0x1F600)
false