Skip to content

Allow CJK / wide-character glyphs to render at natural size (configurable scale floor) #298

@wd

Description

@wd

Summary

Today adjustGlyphs in src/Renderer.zig scales any glyph whose font metrics don't match default_font_info so it fits exactly inside its cell. For CJK characters on macOS this consistently shrinks them to ~84% of ASCII height, which looks visually unbalanced in Chinese / Japanese / Korean text.

face-font-rescale-alist cannot work around this, because Ghostel reads the rescaled glyph height and produces a reciprocal display height that cancels the rescale out.

Why a knob is preferable to a behavior change

I understand the current behavior is the right default — it guarantees strict grid alignment, which is one of the main reasons to use Ghostel over Vterm. The maintainer's rationale in #281 makes the design intent very clear, and I'm not asking to change it.

But for buffers that aren't running a TUI app (a plain shell, or a session that's mostly CJK prose / output), users may want their CJK to render at the font's natural size — at the cost of CJK rows being slightly taller than pure-ASCII rows. That tradeoff is worth exposing as a config.

Proposed configuration

Either of these would work; option 1 is more flexible.

  1. ghostel-cjk-scale-floor (defcustom, float, default 0.0)
    Clamp the computed scale: scale = max(scale_floor, computed_scale). A value of 1.0 disables shrinking entirely; 0.0 keeps current behavior. One @max after the existing @min in adjustGlyphs.

  2. ghostel-disable-glyph-adjust (defcustom, bool, default nil)
    Skip adjustGlyphs entirely when non-nil. Simpler but coarser — also disables the desirable behavior for too-large fallback Nerd-Font glyphs that Nerd Font glyphs render too small #281 fixed.

I'd vote for option 1: it preserves the alignment-correction story for fallback glyphs that are way too big, while still letting CJK render at natural size when the user opts in.

Reproduction

  • Doom Emacs on macOS, ghostel module pulled with ghostel-module-auto-install 'download
  • doom-font = CaskaydiaCove Nerd Font Mono 14pt
  • Global CJK fontset = Sarasa Mono SC (set-fontset-font t 'han ...)
  • Open ghostel, type any CJK character, M-x describe-char
  • Observe: display ((min-width (2)) (height 0.8421052631578947))
  • Setting (setq face-font-rescale-alist '(("Sarasa Mono SC" . 1.3))) has no visible effect — Ghostel reads the rescaled height and emits a reciprocal scale.

Workaround

The only workaround today is to fork and patch src/Renderer.zig (clamp scale to 1.0, or drop the height half of the display spec) and rebuild ghostel-module.dylib. Not great for staying current with upstream.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions