Use the desktop's own monospace font in the terminal
Read org.gnome.desktop.interface monospace-font-name at startup rather than hardcoding a family, so the terminal matches GNOME Terminal exactly and keeps matching after the system font changes. Pango reports points and CSS wants pixels, so 13 becomes 17.33px — rendering it as 13px made the terminal a third too small, which reads as the wrong font rather than the wrong size. The size is the trailing number, since families may contain digits. Families are always quoted, because an unquoted "Noto Sans Mono" is a three-family stack to CSS. Also fixes tests/dial.test.ts, which hardcoded the test server's fingerprint and so went red after every /tmp cleanup. It now asks ssh-keygen, which is a stronger assertion anyway: the expected value comes from the reference implementation rather than from this project's own fingerprint code.
This commit is contained in:
@@ -241,6 +241,26 @@ preload contextBridge,窄白名单 —— 这个文件**就是**
|
||||
|
||||
字节以 `Uint8Array` 跨界,绝不用字符串。TCP 经常把 UTF-8 字符切断在 chunk 之间,单独解码任一半都会损坏它;这个 bug 只在中文或 emoji 输出时出现,因此极易漏掉。
|
||||
|
||||
### 终端字体
|
||||
|
||||
终端使用**桌面自己的等宽字体**——启动时从 `org.gnome.desktop.interface
|
||||
monospace-font-name` 读取。GNOME Terminal 默认是 `use-system-font`,所以这就是
|
||||
**同一个字体**而不是仿制的;而且在用户改了系统设置之后它仍然跟着变,硬编码字
|
||||
体名做不到这一点。
|
||||
|
||||
两个容易搞错的地方:
|
||||
|
||||
- **Pango 用点,CSS 用像素。** GSettings 给的 `13` 是 13pt,当成 13px 渲染会让
|
||||
终端小三分之一——而这读起来像"字体不对",而不是"字号不对"。换算是 96/72。
|
||||
- **尺寸是*最后*一个数字。** 字体名里合法地可以带数字(`Fira Code 2` 就是一个
|
||||
字体名),按第一个数字切会切错。
|
||||
|
||||
字体名在 CSS 值里始终加引号。未加引号的 `Noto Sans Mono` 在 CSS 看来是**三个**
|
||||
字体名组成的栈,终端会静默回退到别的字体。
|
||||
|
||||
不回答的桌面——非 GNOME、或没有 `gsettings`——回退到 `ui-monospace`,那是向引擎
|
||||
要系统等宽字面。同一个请求,只是下沉一层解析。
|
||||
|
||||
### 重连
|
||||
|
||||
传输断开时,`Session` 存活,只替换它底下的 backend——这正是那两者被拆成独立对象的理由。渲染进程保住了滚动历史和标签页,因为终端从未被拆掉。
|
||||
|
||||
Reference in New Issue
Block a user