Skip to content

jamesfishwick/figpreview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

figpreview

The first figlet font picker that reads font headers.

Filter ~700 figlet/toilet fonts by character height, search comment-block descriptors, inspect parsed metadata. Plus the live-preview fzf picker you'd expect.

demo

$ figpreview -i larry3d
larry3d  [figlet]  /opt/homebrew/share/figlet/fonts/larry3d.flf
  format        flf2a$
  height        9 lines/char
  baseline      6
  max width     30
  layout        1
  comments      5 lines
  ---
  larry3d.flf by Larry Gelberg (larryg@avs.com)
  (stolen liberally from Juan Car's puffy.flf)
  tweaked by Glenn Chappell <ggc@uiuc.edu>
  Version 1.2 2/24/94

Why

Existing figlet pickers (including junegunn's canonical figlet.fzf) index by filename. But filenames like larry3d, cybersmall, kontoslant tell you nothing about what the font actually looks like or how tall it is.

Every FLF and TLF file embeds a structured header (character height, baseline, layout flags) plus a free-form comment block (author, date, license, version). figpreview parses both and exposes them as search/filter primitives.

Install

git clone https://github.com/jamesfishwick/figpreview.git
cd figpreview
./install.sh                  # installs to ~/.local/bin/figpreview
./install.sh --with-fonts     # also clones cmatsuoka/figlet-fonts (~700 fonts)

Dependencies (brew install or your distro's package manager):

Tool Required for
figlet rendering .flf fonts
toilet rendering .tlf fonts
fd enumerating font files
unzip reading PK-archived .tlf files (toilet's defaults are ZIP-compressed)
fzf interactive picker (optional - all other modes work without it)

Usage

figpreview                       # fzf picker, live-preview as you scroll
figpreview banner                # render every font matching "banner"
figpreview -s "Your Name"        # custom sample text
figpreview -a | less -R          # full scrollable gallery

Metadata-driven search

figpreview -i larry3d            # full metadata for one font (or pattern)
figpreview -H 8                  # only fonts with character height = 8
figpreview -H :3 -a              # tiniest fonts (height <= 3)
figpreview -H 12: -a             # heaviest fonts (height >= 12)
figpreview -H 6:9                # range
figpreview -g shadow             # comment block mentions "shadow"
figpreview -H :6 -g italic       # filters compose

Reference

Flag Effect
-s TEXT Sample text (default: Hello, or $FIGPREVIEW_SAMPLE)
-i NAME Print parsed header + comment block; substring-matches
-H N / N: / :N / N:M Filter by character height
-g TEXT Filter by comment-block grep (case-insensitive)
-a Dump full gallery to stdout
-h Help

Filters compose. With no pattern, filters narrow the picker; with a pattern, they narrow the rendered set.

Bundled font collection

./install.sh --with-fonts clones cmatsuoka/figlet-fonts to ~/.figlet-fonts (the source of truth, upgrade-proof) and symlinks the .flf/.tlf files into your figlet and toilet font directories. This takes you from the ~250 fonts Homebrew ships to ~700 across categories: BDF/X11 bitmap conversions, C64 fonts, CJK, MS-DOS, and a long tail of contributed ASCII-art fonts.

The symlinks live in Homebrew's Cellar, so brew upgrade figlet will wipe them. Re-run ./install.sh --with-fonts to restore (the clone at ~/.figlet-fonts is untouched).

How metadata reading works

FLF and TLF files start with a single-line header:

flf2a$ 6 5 16 15 11 0 24463 229
^^^^^^ ^ ^ ^^ ^^ ^^
sig+hb h b mw ly cmt-lines  (rest: direction, layout, codetags)

Lines 2 through cmt-lines + 1 are free-form comments (author, date, license). figpreview parses these without loading the glyph data, so filtering across ~700 fonts takes well under a second on cached I/O.

Toilet ships some .tlf fonts as ZIP archives (PK\x03\x04 magic) that toilet itself decompresses at render time. figpreview detects the magic bytes and pipes through unzip -p transparently.

Limitations

  • The interactive picker requires fzf. All other modes (info, gallery, filtered patterns) work without it.
  • -g searches the free-form comment block, which is unreliable: many fonts in the cmatsuoka collection are auto-converted from BDF and share boilerplate attributions. "Most prolific designer" by comment-grep is not a meaningful metric.
  • Rendering depends on terminal UTF-8 support for .tlf fonts (toilet uses Unicode block chars). For CI logs or old TTYs, prefer .flf.

Development

Smoke tests use bats:

brew install bats-core
bats test/

To re-render the demo (requires charm/vhs):

vhs demo.tape

License

WTFPL - do what you want.

Credits

About

figlet font picker with metadata search

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages