Skip to content

[BUG REPORT] 125% 缩放与 16px 字号下制表符基准线宽向下舍入为 1px,导致重竖线 ┃ 过细 #78

Closed

Description

@WhiteGiverMa

Where

Windows

What happened

在 125% 系统缩放(scale = 1.25)与 font_size = 16 配置下,ELYTerminal 自绘的重型制表符(如 OpenCode TUI 左侧边框使用的 ┃ U+2503 与 ╹ U+2579)宽度仅有 2 个物理像素,明显比同字号、同缩放下的 Windows Terminal 和 Ghostty(4 个物理像素)细一半。

Steps to reproduce

  1. 在 125% 显示缩放(120 DPI)下启动 ELYTerminal,将字号设为 16。
  2. 在终端中输出重竖线制表符(如 printf "\u2503\n\u2579\n")或运行使用 ┃ 作为侧边框的 TUI(如 OpenCode)。
  3. 观察 ┃ 的像素宽度(仅 2px),并与 Windows Terminal / Ghostty 对照(4px)。

What you expected

基准线宽 Look.rule 在换算为物理像素时与 Ghostty 的 underline_thickness / box_thickness 保持一致,对非整数物理像素向上取整(ceil):

  • 在 125% 缩放、13px~16px 字号下,基准细线 t 为 2 物理像素,重线 heavy = 2 * t 为 4 物理像素。
  • 在 100% 缩放、13px~14px 默认字号下,(points / 14.) <= 1.0,仍保持 1 物理像素细线与 2 物理像素重线。

Commit or version

  • ELYTerminal 0.2.2,Windows x86_64;main ba664ef6 实现相同。
  • Windows 11 125% 缩放(AppliedDPI = 120)。

Cause

  • src/term/fonts.rs#L76 使用 snap((text / 14.).max(px(1.))) 计算 Look.rule,而 snap 内部采用 .round() 四舍五入。
  • 当 points = 16.0、scale = 1.25 时,(16.0 / 14.0) * 1.25 = 1.4286 < 1.5,.round() 将其向下舍入为 1 物理像素;随后 src/term/paint.rs#L354 得到 t = 1,src/term/boxes.rs#L137 计算出 heavy = 2 * t = 2 物理像素。
  • Ghostty 在 src/font/Metrics.zig 中计算 underline_thickness / box_thickness 时使用的是 @max(1, @ceil(face.underlineThickness())) 向上取整。

Activity

  1. WhiteGiverMa commented on Nov 5, 2026

    @WhiteGiverMa
    ContributorAuthor

    也是在用opencode的时候发现的www

  2. Raiden-MeixElysia commented on Nov 5, 2026

    @Raiden-MeixElysia
    Contributor

    原因和数字写在 #79:同为 16 时,ELY 是 16 px,Ghostty 和 Windows Terminal 是 16 pt(21.3 px)。等你的设置和截图。

  3. WhiteGiverMa commented on Nov 5, 2026

    @WhiteGiverMa
    ContributorAuthor

    补充同一 16 px 字号(Windows Terminal 默认 12 pt = 16 px vs ELYTerminal font_size: 16.0,字体均为 Fira Code,系统缩放 125%)下的对比截图与设置:

    Windows Terminal 12pt (16px) vs ELYTerminal 16px at 125%

    • 上图 Windows Terminal(12 pt = 16 px):Meidocho 左侧 ┃(U+2503)实测宽 4 物理像素(x = 41..44)。
    • 下图 ELYTerminal 0.2.2(16 px):同一位置 ┃ 实测宽 2 物理像素(x = 41..42)。

    详细配置与原因说明已一并回复在 #79。

  4. Raiden-MeixElysia commented on Nov 6, 2026

    @Raiden-MeixElysia
    Contributor

    已在 #79 修复,随 0.2.3 发布。谢谢!

  5. added a commit that references this issue on Nov 6, 2026
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