← Experiments

ChordFont(archived)

Jazz chord symbols, engraved properly — as a font.

npm install @chordlang/font

An OpenType font that sets chord symbols the way jazz lead sheets print them. You type plain ASCII, Ebmaj7 or F#m7b5, and the font draws the flats, sharps, triangle and superscripts. No rendering library, canvas or script runs at display time: the engraving rules live in the font’s substitution tables, so anything that can set a typeface can set chords.

Corpus
142-entry reference lookbook, reference-vs-ours
Distribution
npm @chordlang/*, OFL
Cmaj7 Dm7b5 F♯m7 G13 B♭7 engraved by ChordFont

Context picks the glyph

The hard part of chord engraving is that one keystroke means different things in different places. In Bb7b5, the first b is part of the root, B flat, and the second is an alteration, a flattened fifth. Engravers draw them differently. OpenType’s contextual substitution (GSUB calt) can choose a glyph by what sits to its left, and that is enough to tell them apart.

typedEb7b5glyphsE♭7♭5rootaltsup
Figure 1 Shaping Eb7b5. The font's contextual rules look at the glyph to the left. A b right after a letter A–G becomes the root flat; any other b becomes the smaller, raised alteration flat. A digit becomes superscript only after an alteration, so the 7 stays full size and the 5 is set small and high.

The rules run in order. A flat or sharp right after A–G becomes the root form; any flat or sharp left over becomes the alteration form. A digit after an alteration becomes superscript, and each following digit chains on, so #11 and b13 set as one raised group. Ligatures turn maj into a triangle and dim into a small circle; a 7 after either stays full size.

baselineE♭7♭5
Figure 2 Both flats come from Petaluma's one flat glyph. The root flat is scaled to 0.8 and sits near the baseline, beside the root letter; the alteration flat is scaled to 0.58 and raised to the height of the superscript digit it binds to. Schematic, not to scale.

Two specifications

The font never parses a chord. It maps ASCII to glyphs and nothing more, and its shape tests, run through HarfBuzz, are the engraving spec: Dm7b5 must shape to D m d7 flat.alt d5.sup. A separate chord package, built on tonal, turns messy input into canonical ASCII and the notes it means, and serves as the harmony spec. A stress-test chart renders the whole vocabulary as a regression fixture.

The chordlang monorepo also ships a playground, a lead-sheet format (.cfmd) parsed with Peggy, and harmonic graphs (.cfgv, rendered with Graphviz).

Glyphs and licensing

Glyphs derive from Petaluma (Steinberg’s SMuFL font), under the SIL Open Font License.