Skip to content

Linux: code font selection picks the wrong glyphs under zh_CN.UTF-8 #1304

Done

Description

@duyaofei

问题

Linux 下,在中文区域设置中选择已安装的代码字体,外观预览、编辑器和终端可能画成其他字体(有时是比例字体),而不是设置所选字体。

复现

  1. 使用 LANG=zh_CN.UTF-8、LANGUAGE=zh_CN:zh 启动 BaoCode,不设置 FC_LANG。
  2. 在「设置 → 外观 → 代码字体」中切换两款已安装且字形容易区分的字体,例如 Consolas 和 Courier New,观察预览、打开的文件和终端。
  3. 对照以 FC_LANG=en 启动的结果。这个变量只用于复现对照,不建议作为修复。

预期:已安装字体按设置顺序使用,找不到指定字体才回退到等宽字体,不改变界面的语言或字体匹配。

建议修复

在 Linux runner 使用 Fontconfig 查找所选字体的实际文件,核对匹配字体族后,以私有名称注册给代码渲染;编辑器和终端共用解析结果。预设字体在首帧前注册,避免切换预设时清空 Flutter 字体缓存造成长时间卡顿。保留原始设置,不修改 FC_LANG。

本地 Linux x64 Release 在未设置 FC_LANG 的中文环境中,已验证 Consolas → Courier New 切换会更新预览、已打开的编辑器和终端。还未验证任意自定义字体热切换。希望先确认此方案是否合适,再提交关联 PR。

Activity

  1. added
    accepted
    on Nov 25, 2026
  2. leookun commented on Nov 25, 2026

    @leookun
    Collaborator

    Fixed by #1305: on Linux, code fonts are now found through Fontconfig and loaded under private names, so the editor, the previews and the terminal draw the family that was set under zh_CN.UTF-8 without touching FC_LANG.

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

    accepted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions