4 months ago
- The article discusses the challenges of hand-coding websites, particularly syntax highlighting for code snippets without relying on external libraries.
- A solution is proposed: embedding syntax highlighting directly into a font using OpenType features (COLR table and contextual alternates).
- The modified font (Monaspace Krypton) includes colored versions of characters and uses contextual alternates to highlight syntax based on HTML, CSS, and JS rules.
- Pros of this method: easy installation, no JavaScript required, fast, clean HTML, works in textareas, and supports CSS theming.
- Cons: requires font modification for updates, limited to OpenType-supported environments, basic pattern matching, and no multiline highlighting.
- The article explains the technical implementation, including OpenType COLR tables for multi-colored fonts and contextual alternates for syntax-aware substitutions.
- Future potential includes using harfbuzz-wasm for advanced parsing to overcome current limitations.
- The font is available under the SIL Open Font License, and the project is open for contributions and feedback.