module

ContributorMural::StencilFont

The 5x7 bitmap face the stencil style sets its word in. Rows are written out as #/. so the source doubles as the specimen sheet — a glyph is edited by looking at it, not by counting bits.

This lives outside renderers/ because StencilConfig#validate needs to know which characters exist, and a config that depends on a renderer would be the wrong way round.

Constants

ALPHABET = "A-Z, 0-9, space, and - . ! ? + ' ♥"

What stencil text`` accepts, phrased for the error message. A spec asserts this describes exactly the keys of GLYPHS, so the two cannot drift apart.

BLANK = [".....", ".....", ".....", ".....", ".....", ".....", "....."]
GLYPHS = {' ' => BLANK, 'A' => [".###.", "#...#", "#...#", "#####", "#...#", "#...#", "#...#"], 'B' => ["####.", "#...#", "#...#", "####.", "#...#", "#...#", "####."], 'C' => [".###.", "#...#", "#....", "#....", "#....", "#...#", ".###."], 'D' => ["####.", "#...#", "#...#", "#...#", "#...#", "#...#", "####."], 'E' => ["#####", "#....", "#....", "####.", "#....", "#....", "#####"], 'F' => ["#####", "#....", "#....", "####.", "#....", "#....", "#...."], 'G' => [".###.", "#...#", "#....", "#.###", "#...#", "#...#", ".###."], 'H' => ["#...#", "#...#", "#...#", "#####", "#...#", "#...#", "#...#"], 'I' => ["#####", "..#..", "..#..", "..#..", "..#..", "..#..", "#####"], 'J' => ["..###", "...#.", "...#.", "...#.", "...#.", "#..#.", ".##.."], 'K' => ["#...#", "#..#.", "#.#..", "##...", "#.#..", "#..#.", "#...#"], 'L' => ["#....", "#....", "#....", "#....", "#....", "#....", "#####"], 'M' => ["#...#", "##.##", "#.#.#", "#.#.#", "#...#", "#...#", "#...#"], 'N' => ["#...#", "##..#", "#.#.#", "#.#.#", "#..##", "#...#", "#...#"], 'O' => [".###.", "#...#", "#...#", "#...#", "#...#", "#...#", ".###."], 'P' => ["####.", "#...#", "#...#", "####.", "#....", "#....", "#...."], 'Q' => [".###.", "#...#", "#...#", "#...#", "#.#.#", "#..#.", ".##.#"], 'R' => ["####.", "#...#", "#...#", "####.", "#.#..", "#..#.", "#...#"], 'S' => [".####", "#....", "#....", ".###.", "....#", "....#", "####."], 'T' => ["#####", "..#..", "..#..", "..#..", "..#..", "..#..", "..#.."], 'U' => ["#...#", "#...#", "#...#", "#...#", "#...#", "#...#", ".###."], 'V' => ["#...#", "#...#", "#...#", "#...#", "#...#", ".#.#.", "..#.."], 'W' => ["#...#", "#...#", "#...#", "#.#.#", "#.#.#", "##.##", "#...#"], 'X' => ["#...#", "#...#", ".#.#.", "..#..", ".#.#.", "#...#", "#...#"], 'Y' => ["#...#", "#...#", ".#.#.", "..#..", "..#..", "..#..", "..#.."], 'Z' => ["#####", "....#", "...#.", "..#..", ".#...", "#....", "#####"], '0' => [".###.", "#...#", "#..##", "#.#.#", "##..#", "#...#", ".###."], '1' => ["..#..", ".##..", "..#..", "..#..", "..#..", "..#..", ".###."], '2' => [".###.", "#...#", "....#", "...#.", "..#..", ".#...", "#####"], '3' => ["#####", "...#.", "..#..", "...#.", "....#", "#...#", ".###."], '4' => ["...#.", "..##.", ".#.#.", "#..#.", "#####", "...#.", "...#."], '5' => ["#####", "#....", "####.", "....#", "....#", "#...#", ".###."], '6' => ["..##.", ".#...", "#....", "####.", "#...#", "#...#", ".###."], '7' => ["#####", "....#", "...#.", "..#..", ".#...", ".#...", ".#..."], '8' => [".###.", "#...#", "#...#", ".###.", "#...#", "#...#", ".###."], '9' => [".###.", "#...#", "#...#", ".####", "....#", "...#.", ".##.."], '-' => [".....", ".....", ".....", ".###.", ".....", ".....", "....."], '.' => [".....", ".....", ".....", ".....", ".....", ".##..", ".##.."], '!' => ["..#..", "..#..", "..#..", "..#..", "..#..", ".....", "..#.."], '?' => [".###.", "#...#", "....#", "...#.", "..#..", ".....", "..#.."], '+' => [".....", "..#..", "..#..", "#####", "..#..", "..#..", "....."], '\'' => ["..#..", "..#..", ".....", ".....", ".....", ".....", "....."], '♥' => [".....", ".#.#.", "#####", "#####", "#####", ".###.", "..#.."]}
HEIGHT = 7
WIDTH = 5

Class methods

glyph(char : Char) : Array(String)

Unknown characters render blank. StencilConfig#validate is the gate that tells the user about them, and it runs before any rendering; this fallback only keeps an unvalidated Config.parse from raising.

Source
lines(text : String) : Array(Array(Char))

Normalized lines with trailing blank lines trimmed; interior blank lines are kept and read as a vertical gap.

Source
normalize(text : String) : String

The font is uppercase-only, and ❤ (U+2764, usually with a variation selector) is what people actually paste when they mean ♥.

Source
supports?(char : Char) : Bool
Source