This repository contains a simple web application that lets you render text using classic TheDraw .TDF Color fonts, much like the command-line figlet tool does for its own font format.
It uses an underlying JavaScript library (tdfRenderer.js) to handle the font loading and canvas rendering from a preprocessed binary font bundle.
The core CP437 character rendering logic was adapted from my earlier library, escapes.js.
The TDF-specific parsing (tdfPacker.js, tdfRenderer.js), the binary data bundling strategy, multi-font handling, and the rendering logic were developed primarily through interaction with an AI assistant (Google's Gemini), based on the TDF specification, examples like tdfgo, and specific feature requests during development.
- Renders text using glyphs from preprocessed TDF Color fonts (Type 2).
- Uses a compact Binary bundle (
tdf-fonts.bin) for efficient font data loading. - Simple web interface (
index.html) for text input and font selection. - Handles multi-line text input (
\n). - Configurable text alignment (left, center, right).
- Configurable minimum width for space characters if a font lacks an explicit space glyph.
- "Show All Fonts" mode with virtual rendering (via IntersectionObserver) to handle large font collections.
- Option to filter displayed fonts based on whether they contain all characters in the input text.
To run the index.html web application, you need to preprocess your .TDF font collection into the binary bundle format:
- Gather Fonts: Place your
.TDFfiles into a directory (e.g.,tdf_fonts/). - Preprocess: This project includes
tdfPacker.js. You'll need Node.js installed. Run the script to generate the necessarytdf-fonts.bin:(Make sure# Run the preprocessor script node tdfPacker.js path/to/your/tdf_fonts path/to/output/tdf-fonts.bintdf-fonts.binis saved whereindex.htmlcan fetch it). - CP437 Font Data: The renderer requires CP437 bitmap data. Create a
cp437font.jsfile that assigns the font data array toglobalThis.cp437font. This file must be loaded beforetdfRenderer.js.// Example cp437font.js const cp437FontData = [ /*... 256 rows of 16 bytes ...*/ ]; globalThis.cp437font = cp437FontData;
- Include Scripts: Ensure
index.htmlcorrectly loadscp437font.jsandtdfRenderer.js:<script src="cp437font.js" defer></script> <script src="tdfRenderer.js" defer></script>
After completing the setup:
- Make sure
tdf-fonts.binandcp437font.jsare accessible by the HTML file. - Open
index.htmlin your web browser. - Type text into the input area.
- Select a font from the dropdown.
- Use the checkboxes and number input to control filtering, random order (for "Show All"), minimum space width, and text alignment.
- Click "Show All Fonts" to view the text rendered in all applicable fonts (scroll down to render them as they enter the viewport).
- TheDraw Font Specification: https://www.roysac.com/thedrawfonts-tdf.html (by Roy/SAC)
- Terminal TDF Renderer: tdfgo
MIT.