Skip to content

Custom terminal/chat font, and app-served fonts for phones #204

Closed

Description

@Kuhave

Problem

The terminal font comes from a fixed stack in PaneTerminal.tsx
("JetBrains Mono", "Fira Code", "D2Coding", …, monospace, "Malgun Gothic"), and the first font
installed on the device wins. Only the size is configurable in Settings, not the family.

Desktop. My terminal (Windows Terminal) uses D2Coding, but the web UI picks JetBrains Mono
because it's also installed. The same pane looks different in the TUI and in the browser, and
Hangul alignment differs too: D2Coding draws Hangul at exactly two cells.

Phone. No font in the stack exists on an Android phone, so the terminal falls back to the
generic monospace. Below is the same pane on a Galaxy phone:

  • Left, custom Samsung font style (NanumBarunGothic): Samsung's font style setting replaces
    even Chrome's monospace, so the terminal is drawn in a proportional font. The grid itself
    holds (every | lines up), but i/l are narrower than their cell and m/W spill into the
    next one.
  • Right, default font style: Latin is fine, but Hangul glyphs are narrower than their two
    cells, so syllables get small gaps.
    I've only tested Hangul, but the same should apply to any East Asian wide (two-cell) characters,
    such as Japanese and Chinese, since the fallback glyphs come from proportional system fonts there
    too.
Image
Test pattern used for the screenshots
printf '\033]0;font test\007'; clear; cat <<'EOF'
0123456789012345678901234567890123456789
iiiiiiiiii| this is 'i' x10
llllllllll| this is 'l' x10
mmmmmmmmmm| this is 'm' x10
WWWWWWWWWW| this is 'W' x10
한글한글한| this is Hangul x5 (=10 cells)
가나다라마| this is Hangul x5 (=10 cells)
AB가나CD다| mixed: 4 Latin + 3 Hangul (=10 cells)
+--------+
| box ok |
+--------+
The quick brown fox jumps over the lazy dog
다람쥐 헌 쳇바퀴에 타고파
EOF
read -s

With a proper monospace font, every | sits in the same column and each glyph fills its cell.

Proposal

1. Font family settings

Two text fields in Settings, next to the existing size controls: Terminal font and
Chat font. Each takes a comma-separated list in fallback order, the same way VS Code's
editor.fontFamily / terminal.integrated.fontFamily works:

D2Coding, "Cascadia Mono", monospace
  • The user's list is prepended to the built-in stack rather than replacing it, so a typo or a
    font missing on one device falls back as it does today, and Malgun Gothic stays last as the
    per-glyph Hangul fallback.
  • Empty (the default) keeps today's behavior.
  • Stored per browser like the other appearance settings, so the phone and the desktop can differ.
  • Sanitized like the other settings: length-limited, with characters such as ;, {, }
    stripped.

For the chat, I'm not sure of the right scope: the whole chat body, or only code blocks, which
could simply follow the terminal font. I'd like your view on that.

2. Fonts served by the app (for phones)

A family name alone doesn't help on a phone, because the font isn't installed there. To keep
"nothing leaves the PC", the server would serve user-provided font files:

  • The user drops .woff2/.ttf files into $HERDR_WEB_STATE_DIR/fonts/.
  • The server lists and serves them (for example /api/fonts), behind the same access check as
    the rest of the API.
  • The client registers them with the FontFace API, so the family list from part 1 can name them
    on any device.
  • The service worker caches them, so a phone downloads each file once.

Implementation notes

  • Apply the font on mount (PaneTerminal.tsx ~L218) and in the effect that already handles font
    size changes (~L730), then fit() → resize the same way.
  • Wait for document.fonts.load() before measuring. Otherwise xterm sizes cells from the fallback
    font, and the WebGL renderer caches glyphs from it. After the load, set fontFamily again so
    the atlas is rebuilt.

Would you take a PR?

Is either part something you already have planned? If it fits the direction of the project, I'm
happy to implement it myself, possibly as two PRs: the family settings first, the served fonts
second. If you'd prefer a different UI (for example a preset list instead of free text), please
let me know before I start.

Where

Terminal, Phone, installed app and alerts, Chat and prompt cards

Workarounds and alternatives

What I do now

  • On the phone, I switch Samsung's font style back to the default, which fixes Latin but not the
    Hangul gaps, and changes every other app too.
  • On the phone, I mostly stay in the chat view, which doesn't depend on the terminal grid.
  • On the desktop there's no workaround short of uninstalling the fonts that come earlier in the
    stack.

Other ways this could work

  • Bundle a default monospace font with CJK coverage. No setup for users, but no single choice
    fits everyone: D2Coding covers Korean only, Noto Sans Mono CJK covers all of CJK but runs to tens
    of MB, and Sarasa Mono ships separate SC/TC/J/K builds because Han characters take different
    shapes per region. That's why I lean toward part 2, where each user serves the font that fits
    their language.
  • Load from a CDN such as Google Fonts (Nanum Gothic Coding). Simplest to build, but it adds
    an outbound dependency and breaks offline or closed networks, which goes against "nothing leaves
    the PC".
  • A preset list instead of free text: easier to use, but it can't cover every font someone
    runs in their own terminal.

Activity

  1. added
    enhancement
    on Sep 30, 2026
  2. Kuhave commented on Oct 1, 2026

    @Kuhave
    ContributorAuthor

    @devswha Since #268 mentions this issue, would you be open to taking part 1 first? It's the simple half: Terminal font and Chat font fields in Settings,
    comma-separated and prepended to the built-in stacks (empty keeps today's behavior), stored per browser. The chat font applies to message prose only; code keeps
    --font-mono. It also works alongside #272: a font that already draws CJK at two cells, such as D2Coding, isn't touched by the glyph fitting.

    Part 2 (fonts served by the app) can wait for a separate discussion.

    If that matches the direction you have in mind, the PR is ready to open.

  3. devswha commented on Oct 2, 2026

    @devswha
    Owner

    @Kuhave Yes, please open part 1. It matches what we had in mind:

    • Terminal font and Chat font fields in Settings, comma-separated, prepended to the built-in stacks; empty keeps today's behaviour; stored per browser; sanitized like the other settings.
    • The chat font applies to message prose only; code keeps --font-mono.

    Two things that landed or are landing meanwhile, so the PR can line up with them:

    Part 2 (fonts served by the app) can wait for its own discussion, as you suggested.

    Thanks for the careful write-up and the test pattern; I'll use the pattern to check the PR on a phone and in the iOS simulator.

  4. devswha commented on Oct 3, 2026

    @devswha
    Owner

    Closing, with the remaining half moved to #412.

    Thanks again for the write-up and the PR, @Kuhave.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions