Skip to content

Font Slot Strategy

mdink edited this page Feb 28, 2026 · 1 revision

Font Slot Strategy

What are font slots?

Modern terminal emulators allow you to assign a different font family to each of the four ANSI text attribute combinations:

Slot ANSI codes Example use
Normal (none) Body text / primary coding font
Bold \e[1m Display / heading font
Italic \e[3m Cursive / emphasis font
Bold+Italic \e[1;3m Alternate coding font

When a TUI app emits \e[1m (bold), the terminal automatically switches to whatever font you've configured for the "bold" slot. The app itself doesn't need to know which fonts you've installed — it just needs to emit the right modifier combination.

mdink deliberately maps every markdown element to one of these four slots, giving you typographic richness for free if your terminal is configured with per-slot fonts.


mdink's element-to-slot mapping

Slot Modifier Elements
Normal none Body text, code block body
Bold BOLD h1–h3, **strong**, table headers
Italic ITALIC *emphasis*, links, block quotes, code comments
Bold+Italic BOLD|ITALIC h4–h6, `inline code`

Why these mappings?

  • h1–h3 → Bold: Major headings deserve the display font. Color further distinguishes levels.
  • h4–h6 → Bold+Italic: A third visual texture for subordinate headings without adding color.
  • Inline code → Bold+Italic: Puts the "best" coding font on code within prose.
  • Code block comments → Italic: Matches the popular Operator Mono / Victor Mono convention where comments render in a distinctive cursive font automatically.
  • Links → Italic: The conventional visual cue for hyperlinks in print, applied to the terminal.
  • Body text → Normal: Maximum legibility for reading.

Zero cost for terminals without per-slot fonts

If all four of your terminal's font slots use the same family (which is the default for most users), the visual result is identical to any other markdown renderer: bold text is bold, italic text is italic. The font slot strategy is purely additive — nothing looks worse.


Terminal configuration examples

WezTerm

# ~/.config/wezterm/wezterm.lua
local wezterm = require 'wezterm'

return {
  font = wezterm.font('JetBrains Mono'),
  font_rules = {
    { intensity = 'Bold',   font = wezterm.font('Iosevka',    { weight = 'Bold' }) },
    { italic = true,        font = wezterm.font('Victor Mono', { italic = true }) },
    { intensity = 'Bold', italic = true,
      font = wezterm.font('Fira Code', { weight = 'Bold', italic = true }) },
  },
}

Kitty

# ~/.config/kitty/kitty.conf
font_family      JetBrains Mono
bold_font        Iosevka Bold
italic_font      Victor Mono Italic
bold_italic_font Fira Code Bold Italic

Alacritty

# ~/.config/alacritty/alacritty.toml
[font.normal]
family = "JetBrains Mono"

[font.bold]
family = "Iosevka"

[font.italic]
family = "Victor Mono"
style = "Italic"

[font.bold_italic]
family = "Fira Code"

Code comment italics — the color heuristic

Syntax highlighting libraries (syntect, tree-sitter) return styled token spans. After rendering each span, mdink checks whether the token's foreground color matches the syntect theme's comment color. If it does, ITALIC is added to that span — turning comments into cursive text automatically, on any language, for any syntect theme.

This is more robust than trying to parse scope names (which are not exposed in the rendered-span API) and works correctly for all themes bundled with syntect.

Clone this wiki locally