How to Parse Figlet Font File .FLF #3

schneems opened this Issue Oct 29, 2011 · 5 comments


None yet

5 participants


Hey, i'm interested in writing a pure Ruby implementation of filglet for fun. Do you have any specs for the figlet font files .FLF ? If not how did you figure out how to parse them? Did you just look at another project? If so what project?


Since this issue is high in google results, and I can't find an flf spec anywhere, here's what I've surmised. Throughout this comment I use "character" to refer to ASCII bytes within the .flf file and "letter" to refer to the glyphs defined by the font.

  • .flf files are ASCII text, as you might expect since they're designed to display on terminals in 1994
  • The first line is a header with metadata about the font:
  • The first 5 characters should be flf2a, providing a filetype sigil
  • The next character denotes what character will be used for non-smushable blanks. That is, whatever character is in this position, when that character is encountered in a letter definition, it should be replaced with a space. Using $ here seems common, but of course that won't work if you want to use $s in your letters.
  • Next, there are up to 7 space-separated integers:
    • height (number of rows) of a letter in this font
    • height of a letter, not including descenders
    • width (in columns) of the widest letter in this font
    • default smushmode for this font (analogous to the -m flag to figlet)
    • total number of comment lines in this font file. Comments come immediately after the header and before the first letter definition. Having a character reserved for comments would of course be inconvenient for font authors.
    • 0 if this font should display left-to-right, or 1 if it should display right-to-left.
    • Another number whose meaning I can't quite identify, but which seems to show up in fonts that provide letters at code points outside of ASCII
  • The first five seem mandatory; one or both of the last two are omitted in a lot of fonts and may be later additions to the format.

Next you have the comments, if any, as discussed above.

Finally, the letters, following these rules:

  • Letters are the height specified in the header
  • There're no separating lines between characters
  • The letter is bracketed on the right by a column of characters. This character is the same throughout the font file (i.e. you must pick some character that won't appear in any of your letters).
  • The last line of the letter has an extra bracket-character to the right of the bracketing column.
  • The letters start at space (ASCII 32) and go in ASCII order up to 126
  • The Germans have laid claim to positions 127 through 133, with Ä Ö Ü ä ö ü ß
  • A handful of fonts, such as slant, provide letters at code points above 133, indicated with what looks like the decimal representation of the UTF-8 encoding of the letter and the Unicode description of the letter on a line above the letter definition.
    • figlet-js doesn't appear to support these letters. Honestly I can't blame them; it seems like an awkward tacked-on-later extension to the format. There's even a versioning scheme in the file header! Why not declare a new format-version for Unicode support? :(

@AndrewLorente I believe is the spec you are looking for.


The header line gives information about the FIGfont.  Here is an example
showing the names of all parameters:

          flf2a$ 6 5 20 15 3 0 143 229    NOTE: The first five characters in
            |  | | | |  |  | |  |   |     the entire file must be "flf2a".
           /  /  | | |  |  | |  |   \
  Signature  /  /  | |  |  | |   \   Codetag_Count
    Hardblank  /  /  |  |  |  \   Full_Layout*
         Height  /   |  |   \  Print_Direction
         Baseline   /    \   Comment_Lines
          Max_Length      Old_Layout*

  * The two layout parameters are closely related and fairly complex.


ah-HA! Thanks :)


A very exhaustive document explaining FIGLet / FIGDriver / FIGFonts implementation standard (from 1st version to latest v2.2):

It goes into details on how FIGFonts should be parsed, kerned, smushed, ecc.

[ same as @jarv 's link above, but in HML version ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment