镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Default font stack falls back to PingFang SC before Menlo on macOS, causing wide letter spacing #22

Open

Description

@yulei666

Problem

On macOS, the terminal renders Latin text with very wide letter spacing (e.g. r o o t @ c o d e r), and the glyphs are clearly not a monospace font.

Cause

DEFAULT_FONT_FAMILY in src/prefs.ts lists CJK fonts before the macOS monospace fonts:

"Cascadia Mono", Consolas, "DejaVu Sans Mono", "Liberation Mono", "Noto Sans Mono",
"Noto Sans Mono CJK JP", "Noto Sans CJK JP", "Microsoft YaHei", "MS Gothic", Meiryo,
"PingFang SC", "Hiragino Sans GB", "Noto Color Emoji", Menlo, Monaco, "Courier New", monospace

A stock macOS install has none of the first five fonts, but it does have PingFang SC, so the browser falls back to PingFang (a proportional font) before reaching Menlo. xterm.js sizes each cell from the widest glyph, so narrow letters end up surrounded by large gaps.

The same can happen on Windows with Microsoft YaHei if Cascadia Mono / Consolas are missing.

Suggested fix

Put all monospace fonts ahead of the CJK fallbacks, e.g.:

export const DEFAULT_FONT_FAMILY =
  '"Cascadia Mono", Consolas, "SF Mono", Menlo, Monaco, "DejaVu Sans Mono", "Liberation Mono", '
  + '"Noto Sans Mono", "Courier New", "Noto Sans Mono CJK JP", "Noto Sans CJK JP", "Microsoft YaHei", '
  + '"MS Gothic", Meiryo, "PingFang SC", "Hiragino Sans GB", "Noto Color Emoji", monospace';

It would also help to expose a font-family field in the settings popover (currently only font size is adjustable; fontFamily can only be changed by editing localStorage['web-terminal-prefs']).

Workaround

const k = 'web-terminal-prefs';
const p = JSON.parse(localStorage.getItem(k) || '{}');
p.fontFamily = 'Menlo, Monaco, "SF Mono", "PingFang SC", monospace';
localStorage.setItem(k, JSON.stringify(p));
location.reload();

Environment

  • Plugin version: 1.1.0
  • OS: macOS

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions