UNPKG

bitmapit

Version:

A simple bitmap font generator for creating text art in uppercase letters, designed for ASCII and pixel-style text rendering.

1,099 lines (1,073 loc) 26 kB
export const defaultFont = { 'A': [ [0,1,1,1,1,1,0,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,1,1,1,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'B': [ [1,1,1,1,1,1,0,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,1,1,1,1,0,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'C': [ [0,1,1,1,1,1,0,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,1,1,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'D': [ [1,1,1,1,1,0,0,0], [1,1,0,0,1,1,0,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,1,1,0,0], [1,1,1,1,1,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'E': [ [1,1,1,1,1,1,1,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,1,1,1,0,0,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,1,1,1,1,1,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'F': [ [1,1,1,1,1,1,1,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,1,1,1,0,0,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'G': [ [0,1,1,1,1,1,0,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,0,0,0], [1,1,0,1,1,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'H': [ [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,1,1,1,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'I': [ [1,1,1,1,1,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [1,1,1,1,1,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'J': [ [0,0,1,1,1,1,1,0], [0,0,0,0,1,1,0,0], [0,0,0,0,1,1,0,0], [0,0,0,0,1,1,0,0], [1,1,0,0,1,1,0,0], [1,1,0,0,1,1,0,0], [0,1,1,1,1,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'K': [ [1,1,0,0,0,1,1,0], [1,1,0,0,1,1,0,0], [1,1,0,1,1,0,0,0], [1,1,1,1,0,0,0,0], [1,1,0,1,1,0,0,0], [1,1,0,0,1,1,0,0], [1,1,0,0,0,1,1,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'L': [ [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,1,1,1,1,1,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'M': [ [1,1,0,0,0,1,1,0], [1,1,1,0,1,1,1,0], [1,1,1,1,1,1,1,0], [1,1,0,1,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'N': [ [1,1,0,0,0,1,1,0], [1,1,1,0,0,1,1,0], [1,1,1,1,0,1,1,0], [1,1,0,1,1,1,1,0], [1,1,0,0,1,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'O': [ [0,1,1,1,1,1,0,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'P': [ [1,1,1,1,1,1,0,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,1,1,1,1,0,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'Q': [ [0,1,1,1,1,1,0,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,1,0,1,1,0], [1,1,0,0,1,1,0,0], [0,1,1,1,1,0,1,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'R': [ [1,1,1,1,1,1,0,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,1,1,1,1,0,0], [1,1,0,1,0,0,0,0], [1,1,0,0,1,1,0,0], [1,1,0,0,0,1,1,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'S': [ [0,1,1,1,1,1,0,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,0,0,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'T': [ [1,1,1,1,1,1,1,0], [0,0,1,1,1,0,0,0], [0,0,1,1,1,0,0,0], [0,0,1,1,1,0,0,0], [0,0,1,1,1,0,0,0], [0,0,1,1,1,0,0,0], [0,0,1,1,1,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'U': [ [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'V': [ [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [0,1,1,0,1,1,0,0], [0,0,1,1,1,0,0,0], [0,0,0,1,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'W': [ [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [1,1,0,1,0,1,1,0], [1,1,1,1,1,1,1,0], [1,1,1,0,1,1,1,0], [1,1,0,0,0,1,1,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'X': [ [1,1,0,0,0,1,1,0], [0,1,1,0,1,1,0,0], [0,0,1,1,1,0,0,0], [0,0,0,1,0,0,0,0], [0,0,1,1,1,0,0,0], [0,1,1,0,1,1,0,0], [1,1,0,0,0,1,1,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'Y': [ [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [0,1,1,0,1,1,0,0], [0,0,1,1,1,0,0,0], [0,0,1,1,1,0,0,0], [0,0,1,1,1,0,0,0], [0,0,1,1,1,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), 'Z': [ [1,1,1,1,1,1,1,0], [0,0,0,0,1,1,0,0], [0,0,0,1,1,0,0,0], [0,0,1,1,0,0,0,0], [0,1,1,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,1,1,1,1,1,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '0': [ [0,1,1,1,1,1,0,0], [1,1,0,0,0,1,1,0], [1,1,0,0,1,1,1,0], [1,1,0,1,0,1,1,0], [1,1,1,0,0,1,1,0], [1,1,0,0,0,1,1,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '1': [ [0,0,1,1,1,0,0,0], [0,1,1,1,1,0,0,0], [0,0,1,1,1,0,0,0], [0,0,1,1,1,0,0,0], [0,0,1,1,1,0,0,0], [0,0,1,1,1,0,0,0], [1,1,1,1,1,1,1,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '2': [ [0,1,1,1,1,1,0,0], [1,1,0,0,0,1,1,0], [0,0,0,0,0,1,1,0], [0,0,0,1,1,1,0,0], [0,1,1,1,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,1,1,1,1,1,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '3': [ [0,1,1,1,1,1,0,0], [1,1,0,0,0,1,1,0], [0,0,0,0,0,1,1,0], [0,0,1,1,1,1,0,0], [0,0,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '4': [ [0,0,0,1,1,1,0,0], [0,0,1,1,1,1,0,0], [0,1,1,0,1,1,0,0], [1,1,0,0,1,1,0,0], [1,1,1,1,1,1,1,0], [0,0,0,0,1,1,0,0], [0,0,0,0,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '5': [ [1,1,1,1,1,1,1,0], [1,1,0,0,0,0,0,0], [1,1,1,1,1,1,0,0], [0,0,0,0,0,1,1,0], [0,0,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '6': [ [0,1,1,1,1,1,0,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,0,0,0], [1,1,1,1,1,1,0,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '7': [ [1,1,1,1,1,1,1,0], [0,0,0,0,0,1,1,0], [0,0,0,0,1,1,0,0], [0,0,0,1,1,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '8': [ [0,1,1,1,1,1,0,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [0,1,1,1,1,1,0,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '9': [ [0,1,1,1,1,1,0,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [0,1,1,1,1,1,1,0], [0,0,0,0,0,1,1,0], [1,1,0,0,0,1,1,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), ' ': [ [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '.': [ [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '!': [ [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '@': [ [0,1,1,1,1,1,0,0], [1,0,0,0,0,0,1,0], [1,0,1,1,1,0,1,0], [1,0,1,0,1,0,1,0], [1,0,1,1,1,0,1,0], [1,0,0,0,0,0,1,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '#': [ [0,1,0,1,0,0,0,0], [0,1,0,1,0,0,0,0], [1,1,1,1,1,0,0,0], [0,1,0,1,0,0,0,0], [1,1,1,1,1,0,0,0], [0,1,0,1,0,0,0,0], [0,1,0,1,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '$': [ [0,0,1,1,1,0,0,0], [0,1,1,0,0,1,0,0], [0,1,1,0,0,0,0,0], [0,0,1,1,1,0,0,0], [0,0,0,0,1,1,0,0], [1,0,0,1,1,0,0,0], [0,1,1,1,0,0,0,0], [0,0,1,0,0,0,0,0] ].map(row => row.map(Boolean)), '%': [ [1,1,0,0,0,1,0,0], [1,1,0,0,1,0,0,0], [0,0,0,1,0,0,0,0], [0,0,1,0,0,0,0,0], [0,1,0,0,0,0,0,0], [1,0,0,0,1,1,0,0], [0,0,0,0,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '&': [ [0,1,1,1,0,0,0,0], [1,0,0,0,1,0,0,0], [1,0,0,0,1,0,0,0], [0,1,1,1,0,1,0,0], [1,0,0,0,1,0,0,0], [1,0,0,0,1,0,0,0], [0,1,1,1,0,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '*': [ [0,0,1,0,1,0,0,0], [0,0,0,1,0,0,0,0], [1,1,1,1,1,0,0,0], [0,0,1,1,0,0,0,0], [0,1,0,1,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '+': [ [0,0,0,0,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [1,1,1,1,1,1,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '-': [ [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [1,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '=': [ [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [1,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0], [1,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '?': [ [0,1,1,1,1,1,0,0], [1,0,0,0,0,1,1,0], [0,0,0,0,1,1,0,0], [0,0,0,1,1,0,0,0], [0,0,1,1,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '/': [ [0,0,0,0,0,1,1,0], [0,0,0,0,1,1,0,0], [0,0,0,1,1,0,0,0], [0,0,1,1,0,0,0,0], [0,1,1,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '\\': [ [1,1,0,0,0,0,0,0], [0,1,1,0,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,0,1,1,0,0,0], [0,0,0,0,1,1,0,0], [0,0,0,0,0,1,1,0], [0,0,0,0,0,0,1,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '(': [ [0,0,1,1,0,0,0,0], [0,1,1,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [0,1,1,0,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), ')': [ [0,0,1,1,0,0,0,0], [0,0,0,1,1,0,0,0], [0,0,0,0,1,1,0,0], [0,0,0,0,1,1,0,0], [0,0,0,0,1,1,0,0], [0,0,0,1,1,0,0,0], [0,0,1,1,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '[': [ [1,1,1,1,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,0,0,0,0,0,0], [1,1,1,1,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), ']': [ [0,1,1,1,1,0,0,0], [0,0,0,1,1,0,0,0], [0,0,0,1,1,0,0,0], [0,0,0,1,1,0,0,0], [0,0,0,1,1,0,0,0], [0,0,0,1,1,0,0,0], [0,1,1,1,1,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '{': [ [0,0,1,1,1,0,0,0], [0,1,1,0,0,0,0,0], [0,1,1,0,0,0,0,0], [1,1,0,0,0,0,0,0], [0,1,1,0,0,0,0,0], [0,1,1,0,0,0,0,0], [0,0,1,1,1,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '}': [ [1,1,1,0,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,0,1,1,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [1,1,1,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), ':': [ [0,0,0,0,0,0,0,0], [0,1,1,0,0,0,0,0], [0,1,1,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,1,1,0,0,0,0,0], [0,1,1,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), ';': [ [0,0,0,0,0,0,0,0], [0,1,1,0,0,0,0,0], [0,1,1,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,1,1,0,0,0,0,0], [0,0,1,0,0,0,0,0], [0,1,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '"': [ [1,1,0,1,1,0,0,0], [1,1,0,1,1,0,0,0], [1,0,0,1,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '\'': [ [0,1,1,0,0,0,0,0], [0,1,1,0,0,0,0,0], [0,1,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), ',': [ [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,1,1,0,0,0,0,0], [0,0,1,0,0,0,0,0], [0,1,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '_': [ [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [1,1,1,1,1,1,1,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '|': [ [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), // Greek Letters 'π': [ [0,1,1,1,1,0,0,0], [1,0,0,0,0,1,0,0], [1,0,0,0,0,1,0,0], [1,1,1,1,1,1,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), // Currency Symbols '€': [ [0,0,1,1,1,1,0,0], [0,1,1,0,0,0,0,0], [1,1,1,1,1,0,0,0], [0,1,1,0,0,0,0,0], [1,1,1,1,1,0,0,0], [0,1,1,0,0,0,0,0], [0,0,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '£': [ [0,0,1,1,1,1,0,0], [0,1,1,0,0,0,0,0], [0,1,1,0,0,0,0,0], [1,1,1,1,1,0,0,0], [0,1,1,0,0,0,0,0], [0,1,1,0,0,0,0,0], [1,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '¥': [ [1,1,0,0,0,1,1,0], [0,1,1,0,1,1,0,0], [0,0,1,1,1,0,0,0], [0,0,1,1,1,0,0,0], [1,1,1,1,1,1,1,0], [0,0,1,1,1,0,0,0], [0,0,1,1,1,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), // Arrows '←': [ [0,0,0,0,0,0,0,0], [0,0,0,1,0,0,0,0], [0,0,1,0,0,0,0,0], [1,1,1,1,1,1,0,0], [0,0,1,0,0,0,0,0], [0,0,0,1,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '→': [ [0,0,0,0,0,0,0,0], [0,0,0,1,0,0,0,0], [0,0,0,0,1,0,0,0], [1,1,1,1,1,1,0,0], [0,0,0,0,1,0,0,0], [0,0,0,1,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '↑': [ [0,0,0,1,0,0,0,0], [0,0,1,1,1,0,0,0], [0,1,0,1,0,1,0,0], [0,0,0,1,0,0,0,0], [0,0,0,1,0,0,0,0], [0,0,0,1,0,0,0,0], [0,0,0,1,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '↓': [ [0,0,0,1,0,0,0,0], [0,0,0,1,0,0,0,0], [0,0,0,1,0,0,0,0], [0,0,0,1,0,0,0,0], [0,1,0,1,0,1,0,0], [0,0,1,1,1,0,0,0], [0,0,0,1,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), // Special Symbols '©': [ [0,1,1,1,1,1,0,0], [1,0,1,1,1,0,1,0], [1,1,0,0,0,1,1,0], [1,1,0,0,0,0,1,0], [1,1,0,0,0,1,1,0], [1,0,1,1,1,0,1,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '®': [ [0,1,1,1,1,1,0,0], [1,0,1,1,1,0,1,0], [1,1,0,0,0,1,1,0], [1,1,1,1,1,0,1,0], [1,1,0,1,0,1,1,0], [1,0,0,0,1,0,1,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), // Box Drawing '┌': [ [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,1,1,1,1,1,0,0], [0,1,0,0,0,0,0,0], [0,1,0,0,0,0,0,0], [0,1,0,0,0,0,0,0], [0,1,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '┐': [ [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,1,0,0], [0,0,0,0,0,1,0,0], [0,0,0,0,0,1,0,0], [0,0,0,0,0,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '└': [ [0,1,0,0,0,0,0,0], [0,1,0,0,0,0,0,0], [0,1,0,0,0,0,0,0], [0,1,0,0,0,0,0,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '┘': [ [0,0,0,0,0,1,0,0], [0,0,0,0,0,1,0,0], [0,0,0,0,0,1,0,0], [0,0,0,0,0,1,0,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), // Math Symbols '×': [ [0,0,0,0,0,0,0,0], [1,0,0,0,0,1,0,0], [0,1,0,0,1,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,1,0,0,1,0,0,0], [1,0,0,0,0,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '÷': [ [0,0,0,0,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [1,1,1,1,1,1,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '±': [ [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [1,1,1,1,1,1,0,0], [0,0,1,1,0,0,0,0], [0,0,1,1,0,0,0,0], [0,0,0,0,0,0,0,0], [1,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), // Emoticons and Fun Symbols '^': [ [0,0,1,1,1,0,0,0], [0,1,0,0,0,1,0,0], [1,0,0,0,0,0,1,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '_': [ [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0], [1,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '♥': [ [0,1,1,0,1,1,0,0], [1,1,1,1,1,1,1,0], [1,1,1,1,1,1,1,0], [1,1,1,1,1,1,1,0], [0,1,1,1,1,1,0,0], [0,0,1,1,1,0,0,0], [0,0,0,1,0,0,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '☺': [ [0,1,1,1,1,1,0,0], [1,0,0,0,0,0,1,0], [1,0,1,0,1,0,1,0], [1,0,0,0,0,0,1,0], [1,0,1,1,1,0,1,0], [1,0,0,0,0,0,1,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '☹': [ [0,1,1,1,1,1,0,0], [1,0,0,0,0,0,1,0], [1,0,1,0,1,0,1,0], [1,0,0,0,0,0,1,0], [1,0,0,1,0,0,1,0], [1,0,1,1,1,0,1,0], [0,1,1,1,1,1,0,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), '★': [ [0,0,0,1,0,0,0,0], [0,0,1,1,1,0,0,0], [1,1,1,1,1,1,1,0], [0,1,1,1,1,1,0,0], [0,0,1,1,1,0,0,0], [0,1,0,1,0,1,0,0], [1,0,0,1,0,0,1,0], [0,0,0,0,0,0,0,0] ].map(row => row.map(Boolean)), }; export class BitmapFontGenerator { constructor(options = {}) { this.width = options.width || 8; this.height = options.height || 8; this.spacing = options.spacing || 1; this.displayOptions = { on: options.onChar || '█', off: options.offChar || ' ', color: options.color || '#ffffff', backgroundColor: options.backgroundColor || 'transparent' }; this.font = new Map(); this.originalPatterns = new Map(); // Store original patterns } /** * Define a character in the bitmap font * @param {string} char - Single character to define * @param {boolean[][]} pattern - 2D array representing the bitmap pattern */ defineCharacter(char, pattern) { // Store original pattern this.originalPatterns.set(char.toUpperCase(), pattern); // Scale pattern to current dimensions const scaledPattern = this.scalePattern(pattern); this.font.set(char.toUpperCase(), scaledPattern); } /** * Scale a pattern to match current dimensions * @param {boolean[][]} pattern - Original pattern * @returns {boolean[][]} Scaled pattern */ scalePattern(pattern) { const originalHeight = pattern.length; const originalWidth = pattern[0].length; const result = Array(this.height).fill().map(() => Array(this.width).fill(false)); for (let y = 0; y < this.height; y++) { for (let x = 0; x < this.width; x++) { // Map current coordinates to original pattern coordinates const origX = Math.floor(x * originalWidth / this.width); const origY = Math.floor(y * originalHeight / this.height); result[y][x] = pattern[origY][origX]; } } return result; } /** * Regenerate all font patterns with new dimensions */ regeneratePatterns() { this.font.clear(); this.originalPatterns.forEach((pattern, char) => { const scaledPattern = this.scalePattern(pattern); this.font.set(char, scaledPattern); }); } /** * Generate bitmap text * @param {string} text - Text to render * @returns {boolean[][]} - 2D array representing the bitmap text */ generateText(text) { const upperText = text.toUpperCase(); const result = Array(this.height).fill().map(() => []); for (let i = 0; i < upperText.length; i++) { const char = upperText[i]; const pattern = this.font.get(char); if (!pattern) continue; // Add character pattern for (let y = 0; y < this.height; y++) { for (let x = 0; x < this.width; x++) { result[y].push(pattern[y][x]); } // Add spacing between characters if (i < upperText.length - 1) { for (let s = 0; s < this.spacing; s++) { result[y].push(false); } } } } return result; } /** * Convert bitmap to ASCII art * @param {boolean[][]} bitmap - 2D array representing the bitmap * @param {Object} options - Display options * @returns {string} ASCII art representation */ toAscii(bitmap, options = {}) { const displayChar = options.on || this.displayOptions.on; const emptyChar = options.off || this.displayOptions.off; return bitmap.map(row => row.map(pixel => pixel ? displayChar : emptyChar).join('') ).join('\n'); } /** * Convert bitmap to HTML * @param {boolean[][]} bitmap - 2D array representing the bitmap * @param {Object} options - Display options * @returns {string} HTML representation */ toHtml(bitmap, options = {}) { const color = options.color || this.displayOptions.color; const backgroundColor = options.backgroundColor || this.displayOptions.backgroundColor; const displayChar = options.on || this.displayOptions.on; const emptyChar = options.off || this.displayOptions.off; const asciiArt = this.toAscii(bitmap, { on: displayChar, off: emptyChar }); return `<pre style="color: ${color}; background-color: ${backgroundColor}; font-family: monospace;">${asciiArt}</pre>`; } /** * Set the display character for filled pixels * @param {string} char - Character to use for filled pixels */ setDisplayChar(char) { this.displayOptions.on = char; } /** * Set the display character for empty pixels * @param {string} char - Character to use for empty pixels */ setEmptyChar(char) { this.displayOptions.off = char; } /** * Set the text color * @param {string} color - CSS color value */ setColor(color) { this.displayOptions.color = color; } /** * Set the background color * @param {string} color - CSS color value */ setBackgroundColor(color) { this.displayOptions.backgroundColor = color; } /** * Set the font dimensions * @param {number} width - Width of each character * @param {number} height - Height of each character */ setDimensions(width, height) { if (width) this.width = width; if (height) this.height = height; this.regeneratePatterns(); } /** * Set the spacing between characters * @param {number} spacing - Number of pixels between characters */ setSpacing(spacing) { this.spacing = spacing; } /** * Get current display options * @returns {Object} Current display options */ getDisplayOptions() { return { ...this.displayOptions }; } /** * Get current dimensions * @returns {Object} Current width, height, and spacing */ getDimensions() { return { width: this.width, height: this.height, spacing: this.spacing }; } /** * Reset display options to defaults */ resetDisplayOptions() { this.displayOptions = { on: '█', off: ' ', color: '#ffffff', backgroundColor: 'transparent' }; } /** * Create a styled text output * @param {string} text - Text to render * @param {Object} options - Display options * @returns {string} Formatted text output */ createText(text, options = {}) { const bitmap = this.generateText(text); return options.html ? this.toHtml(bitmap, options) : this.toAscii(bitmap, options); } }