Skip to content

Auto-detect Nerd Font availability instead of a fixed icons default #611

Description

@eugenioenko

Summary

#606 added Nerd Font file-type icons to the Explorer and Changes panel (explorer.icons / git.icons, "nerd-font" | "none"). Without a Nerd Font installed, the glyphs render as broken boxes, so the setting currently has to default conservatively (see the discussion on #606: "There doesn't seem to be a reliable way to detect if the font is available").

This issue tracks doing that detection properly, so icons can default to on for users who'll actually see them, without breaking the terminal for everyone else.

The problem

ttt runs inside an arbitrary terminal emulator and has no reliable way to ask "is the font you're rendering with a Nerd Font (or does it otherwise cover the glyph ranges we use)?" There's no escape sequence or env var that reports the active font. Fallback to plain Unicode was tried before (#135) and rejected as too visually busy.

Possible directions (not settled, open to better ideas)

  • Cell-width probing: query the terminal's reported width for a couple of known Nerd Font codepoints (via a CSI cell-size / cursor-position round trip similar to the appearance query added in feat: auto theme follows terminal appearance #607) and infer coverage from whether it renders as expected vs. a fallback-width box.
  • A one-time onboarding check: show a small sample of the glyphs on first run and ask "do these look right?", persisting the answer to settings instead of guessing silently.
  • Known-terminal allowlist: some terminals/configs (e.g. ships with a Nerd Font patched build, or common setups like Ghostty + a Nerd Font default) could be inferred from TERM_PROGRAM/similar env vars as a low-confidence heuristic, falling back to the explicit setting otherwise.

Whatever approach: it needs to fail safe (default to none on any doubt), since a broken glyph is a worse first impression than a missing icon.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions