Skip to content

fix(fonts): match Ghostty CJK width scaling - #31

Merged
wiedymi merged 1 commit into
mainfrom
agent/fix-cjk-ic-width-scaling
Jul 16, 2026
Merged

fix(fonts): match Ghostty CJK width scaling#31
wiedymi merged 1 commit into
mainfrom
agent/fix-cjk-ic-width-scaling

Conversation

@wiedymi

@wiedymi wiedymi commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • replace the wide-fallback primary-em shortcut with Ghostty's default em-normalized ic_width adjustment
  • measure the primary printable-ASCII box and the fallback advance, with Ghostty-compatible ex-height, cap-height, and line-height fallbacks
  • share the metric implementation between WebGPU and WebGL2 while preserving the common baseline and two-cell safety cap
  • add regression coverage using the bundled JetBrains Mono and Noto Sans CJK metrics
  • prepare restty 0.2.4

Root cause

Version 0.2.3 forced wide fallback faces to the primary em scale but bypassed the existing metric adjustment. Ghostty instead scales ordinary fallback faces by an em-normalized ic_width ratio. For the bundled fonts, this ratio is 1050 / 1000 = 1.05; retaining it increases the CJK advance from 13.64 px to 14.32 px in a 16 px two-cell span and removes the excess whitespace.

Validation

  • bun test tests/fallback-font-layout.test.ts tests/symbol-rendering.test.ts
  • PowerShell equivalent of bun run test:ci: 316 tests passed
  • live bundled-font metric probe: metricAdjust=1.05, advancePx=14.3181818
  • bun run build:types
  • bun run check:themes
  • bun run format:check
  • bun run lint
  • bun run build
  • bun run playground:build
  • release-note extraction for 0.2.4

Fixes #24

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying restty with  Cloudflare Pages  Cloudflare Pages

Latest commit: b5a444e
Status: ✅  Deploy successful!
Preview URL: https://f6a251a5.restty.pages.dev
Branch Preview URL: https://agent-fix-cjk-ic-width-scali.restty.pages.dev

View logs

@wiedymi
wiedymi marked this pull request as ready for review July 16, 2026 15:03
@wiedymi
wiedymi merged commit 38d9adb into main Jul 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CJK fallback glyphs are upscaled to fill double-width cells and float above the latin baseline

1 participant