Living Document Notice
Published 2026-09-17. The evolving architecture, revisions, and connected notes for this dispatch live in the Stax Digital Garden.
Algorithmic Kerning and OpenType Feature Invariants in Terminal Parsers
Terminal text engines format characters into rigid monospaced grids. In book production, however, proportional typography requires precise glyph shaping, ligature substitution, and fractional kerning pair adjustments. The Bosun Press formatting engine integrates the HarfBuzz shaping engine into local terminal compilation pipelines.
OpenType Shaping Pipeline
Raw UTF-8 text strings pass through HarfBuzz to compute byte-exact glyph cluster positions and contextual alternates:
#include <hb.h>
#include <hb-ft.h>
void shape_line_segment(hb_font_t *font, const char *text, int len) {
hb_buffer_t *buf = hb_buffer_create();
hb_buffer_add_utf8(buf, text, len, 0, len);
hb_buffer_guess_segment_properties(buf);
// Enable discretionary ligatures and proportional figures
hb_feature_t features[2];
hb_feature_from_string("dlig 1", -1, &features[0]);
hb_feature_from_string("pnum 1", -1, &features[1]);
hb_shape(font, buf, features, 2);
unsigned int glyph_count;
hb_glyph_position_t *pos = hb_buffer_get_glyph_positions(buf, &glyph_count);
// Render glyphs with sub-pixel horizontal advance offsets
hb_buffer_destroy(buf);
}This ensures mathematical symbols, programming ligatures, and small caps render cleanly on high-resolution plates without visual collisions.
Microtypography Invariants
To achieve publication-grade readability across technical manuals, the layout engine enforces three microtypographic invariants:
- Hyphenation Frequency: No more than two consecutive lines may end in hyphenated breaks.
- Tracking Adjustments: Line-fitting adjusts inter-character tracking within a narrow -0.02em to +0.03em envelope.
- Orphan Control: Paragraph terminal lines must contain at least two full words totaling seven characters minimum.
- Directus Target: press
- Garden Source Reference: MOC - Typography & Physical Print Specifications, MOC - Bosun PKM Tools
- Garden Source Reference: [PRS-1006 - Algorithmic Kerning and OpenType Feature Invariants in Terminal Parsers](PRS-1006 - Algorithmic Kerning and OpenType Feature Invariants in Terminal Parsers)