Polyfont

Per-token font highlighting for code editors

Go beyond color. Use different fonts for keywords, functions, comments, strings, and more.

Get Started

What it does

Most code editors support per-token color highlighting. Polyfont extends this to per-token font highlighting. Assign distinct font families, weights, and styles to different syntax tokens -- keywords in Maple Mono Bold, functions in Monaspace Argon, comments in IBM Plex Mono Italic, strings in Source Code Pro Light.

Example

fn calculate_total(items: &[Item]) -> f64 {    <-- keyword (Maple Mono Bold)
// Computes the total price                    <-- comment (IBM Plex Mono Italic)
    let sum: f64 = items                       <-- variable (JetBrains Mono)
        .iter()                                <-- function (Monaspace Argon)
        .map(|item| item.price)                <-- function (Monaspace Argon)
        .sum();                                <-- method (Monaspace Krypton)
    sum * 1.08                                 <-- constant (Monaspace Radon)
}                                              <-- punctuation (Fira Code)

Architecture

+--------------------------------------------------+
|  .polyfont.toml                                   |
|  Config: scope -> font mappings                   |
+---------------------------+------------------------+
                             |
               +-------------+-------------+
               |       polyfont-core       |
               |   Rust library            |
               |   Scope resolution        |
               |   Font assignment         |
               +--+-------------+----------+
                  |             |          |
     +------------+   +---------+   +------+------------+
     |  VSCode    |   | Neovim  |   |  CLI / LSP        |
     |  Extension |   | Plugin  |   |  polyfont check   |
     |            |   |         |   |  polyfont vscode  |
     | textMate   |   | Tree-   |   |  polyfont neovim  |
     | Rules API  |   | sitter  |   |  polyfont kitty   |
     |            |   | +extmarks|  |  polyfont font    |
     +------------+   +---------+   |  polyfont theme   |
                                   +-------------------+

Features

  • 8 Rust crates -- core, config, scope, parse, fonts, themes, lsp, cli
  • Tree-sitter parsing -- 10 language grammars with naive fallback
  • Trie-based scope matching -- O(k) lookup, scales to 500+ rules
  • Cross-platform font discovery -- Linux, macOS, Windows auto-detection
  • 5 built-in themes -- monaspace, serif-mono, weight-differentiated, minimal, maximal
  • Theme import/export -- VSCode and TextMate JSON compatibility
  • 6 editor integrations -- VSCode, Neovim, Zed, Helix, Sublime, Kitty
  • 120 tests -- unit tests across all crates, criterion benchmarks

Documentation

Getting Started

Install Polyfont, create your first config, and apply fonts in your editor.

Configuration

Complete reference for .polyfont.toml: schema, scope matching, font weights, and all example rules.

Editor Integration

VSCode, Neovim, Kitty terminal setup guides, compatibility matrix, and troubleshooting.

API Reference

Rust crate documentation for polyfont-core, polyfont-config, polyfont-scope, and polyfont-lsp.