Syntax highlighting—essential for code readability—traditionally requires grammar processors like Prism.js or Pygments. These tools add computational overhead and complicate document workflows. At the recent TUG2025 conference, researcher Rajeesh Nambiar unveiled a groundbreaking alternative: a font with native syntax highlighting capabilities for TeX and LaTeX documents.

Inspired by Heikki Lotvonen's HTML/CSS highlighting font, Nambiar's creation uses OpenType's COLRv0 and COLRv1 specifications to dynamically colorize TeX syntax. Unlike external processors, the font handles highlighting intrinsically through specialized shaping rules embedded within the font file itself.

Article illustration 1

Key technical innovations include:
- Dual support for COLRv0 and COLRv1 color formats
- Recognition of plain TeX, LaTeX2, and LaTeX3 macros
- Optimized OpenType shaping tables mapping syntax patterns to color layers

The font builds upon M+ Code Latin by Coji Morishita, maintaining its typographic integrity while adding semantic coloration. During compilation or rendering, characters automatically adopt colors based on their syntactic role—commands, arguments, or special characters—without auxiliary software.

"This shifts syntax highlighting from software to typeface design," notes Nambiar in his TUGboat journal article. "Editors and typesetting systems render colored output by simply using the font."

While ideal for lightweight scenarios like documentation snippets, the approach has limitations in handling complex nested macros. The fonts and source files are publicly available, inviting community refinement. For TeX practitioners, this innovation reimagines how developer tooling intersects with typography—proving that sometimes, the most elegant solutions reside in the glyphs themselves.

Source: Rajeesh Nambiar's blog and TUGboat 46:2