FIGfont Version 2 file parsing and loading.
A FIGfont file (.flf) is a plain text file containing the graphical arrangements of sub-characters that compose each FIGcharacter. This namespace handles every stage of reading one into a Clojure map: header parsing, layout parameter interpretation, comment skipping, endmark stripping, and extraction of both the 102 required FIGcharacters (ASCII 32-126 plus 7 Deutsch) and any code-tagged extras.
The font map returned by load-font is a plain Clojure map — no
custom types or protocols — so fonts compose naturally with the rest
of the language: they can be merged, filtered, assoc'd with overrides,
serialized, or passed through any data pipeline.
See figfont.txt §CREATING FIGFONTS for the full specification.
FIGfont Version 2 file parsing and loading. A FIGfont file (.flf) is a plain text file containing the graphical arrangements of sub-characters that compose each FIGcharacter. This namespace handles every stage of reading one into a Clojure map: header parsing, layout parameter interpretation, comment skipping, endmark stripping, and extraction of both the 102 required FIGcharacters (ASCII 32-126 plus 7 Deutsch) and any code-tagged extras. The font map returned by `load-font` is a plain Clojure map — no custom types or protocols — so fonts compose naturally with the rest of the language: they can be merged, filtered, assoc'd with overrides, serialized, or passed through any data pipeline. See figfont.txt §CREATING FIGFONTS for the full specification.
(all-fonts)Returns a sorted vector of bundled font names (without path or extension), discovered from the fonts/ directory on the classpath.
Returns a sorted vector of bundled font names (without path or extension), discovered from the fonts/ directory on the classpath.
(load-font source)Loads a FIGfont file and returns a font map. source may be a classpath
resource path (e.g. "fonts/standard.flf"), a filesystem path string, a
java.io.File, or a java.io.Reader. Classpath resources are tried first
when given a string.
The returned map contains the following keys:
:hardblank Character used as the hardblank sub-character. :height Number of rows in every FIGcharacter. :baseline Rows from the top to the baseline (for alignment). :max-length Maximum line width in the font file. :old-layout Legacy layout parameter (Old_Layout, -1 to 63). :full-layout Full layout parameter (Full_Layout, 0 to 32767), or nil. :comment-lines Number of comment lines in the font file. :print-direction Default print direction (0 = left-to-right). :codetag-count Number of code-tagged characters, or nil. :h-layout Horizontal layout mode (:full, :fitting, or :smushing). :h-smush-rules Set of active horizontal smushing rule numbers (1-6). :v-layout Vertical layout mode (:full, :fitting, or :smushing). :v-smush-rules Set of active vertical smushing rule numbers (1-5). :chars Map of character code (long) to FIGcharacter data, where each FIGcharacter is a vector of strings (one per row).
Loads a FIGfont file and returns a font map. `source` may be a classpath
resource path (e.g. "fonts/standard.flf"), a filesystem path string, a
java.io.File, or a java.io.Reader. Classpath resources are tried first
when given a string.
The returned map contains the following keys:
:hardblank Character used as the hardblank sub-character.
:height Number of rows in every FIGcharacter.
:baseline Rows from the top to the baseline (for alignment).
:max-length Maximum line width in the font file.
:old-layout Legacy layout parameter (Old_Layout, -1 to 63).
:full-layout Full layout parameter (Full_Layout, 0 to 32767), or nil.
:comment-lines Number of comment lines in the font file.
:print-direction Default print direction (0 = left-to-right).
:codetag-count Number of code-tagged characters, or nil.
:h-layout Horizontal layout mode (:full, :fitting, or :smushing).
:h-smush-rules Set of active horizontal smushing rule numbers (1-6).
:v-layout Vertical layout mode (:full, :fitting, or :smushing).
:v-smush-rules Set of active vertical smushing rule numbers (1-5).
:chars Map of character code (long) to FIGcharacter data, where
each FIGcharacter is a vector of strings (one per row).(valid-font? font-or-source)Returns true if the font has no spec violations. Accepts anything
load-font accepts: a font map, a classpath resource path, a
filesystem path, a File, or a Reader.
Returns true if the font has no spec violations. Accepts anything `load-font` accepts: a font map, a classpath resource path, a filesystem path, a File, or a Reader.
(validate-font font)Validates a loaded font map against the FIGfont Version 2 specification using clojure.spec. Returns nil if valid, or a spec explain-data map describing the violations.
Validates a loaded font map against the FIGfont Version 2 specification using clojure.spec. Returns nil if valid, or a spec explain-data map describing the violations.
(write-font font
dest
&
{:keys [comments endmark]
:or {comments ["Written by clj-figlet"] endmark \@}})Serializes a font map to FIGfont Version 2 format and writes it to dest.
dest may be anything accepted by clojure.java.io/writer (a path string,
File, OutputStream, etc.).
The font is validated against the spec before writing; throws ex-info if validation fails.
comments is an optional vector of comment lines to include after the
header. If omitted, a single attribution line is written.
See figfont.txt §CREATING FIGFONTS for the file format.
Serializes a font map to FIGfont Version 2 format and writes it to `dest`. `dest` may be anything accepted by `clojure.java.io/writer` (a path string, File, OutputStream, etc.). The font is validated against the spec before writing; throws ex-info if validation fails. `comments` is an optional vector of comment lines to include after the header. If omitted, a single attribution line is written. See figfont.txt §CREATING FIGFONTS for the file format.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |