Skip to content

fix: render on Ghostty's physical pixel grid - #3

Merged
Hona merged 3 commits into
mainfrom
fix-dpr-rendering
Jul 20, 2026
Merged

fix: render on Ghostty's physical pixel grid#3
Hona merged 3 commits into
mainfrom
fix-dpr-rendering

Conversation

@Hona

@Hona Hona commented Jul 20, 2026

Copy link
Copy Markdown
Member

Summary

  • rebuild canvas and font metrics when browser DPR changes instead of scaling a stale backing store
  • derive CSS dimensions from integer physical cells and paint contiguous backgrounds as exact physical-pixel runs
  • expose Ghostty core's real font.sprite.Face rasterizer through the WASM API
  • render Ghostty-native block, box, braille, Powerline, branch, geometric, and legacy-computing sprites instead of font approximations
  • snap decorations and cursors to Ghostty-derived integer physical metrics

Source of truth

The implementation follows the pinned Ghostty core:

  • src/font/Metrics.zig: physical cell width/height round to nearest integer
  • src/renderer/shaders/glsl/cell_bg.f.glsl: backgrounds resolve from physical pixel to cell
  • src/font/sprite/Face.zig: canonical sprite range dispatch and rasterization
  • src/font/sprite/draw/*: canonical Ghostty geometry

No glyph geometry is copied from xterm.js or Windows Terminal. TypeScript only handles browser DPR, tinting, caching, and compositing of Ghostty-produced A8 masks.

Visual validation

A Playwright-driven Electron harness initialized at 100%, changed zoom without reload, and captured old/reloaded/fixed output at 80%, 125%, and 150%.

  • old live zoom retained a 1.00 backing ratio
  • old reload rebuilt at the target ratio
  • fixed live zoom rebuilt immediately at 0.80, 1.25, and 1.50
  • fixed solid backgrounds have no internal cell outlines
  • fixed Powerline and block glyphs use Ghostty core masks

Verification

  • bun test (365 passed)
  • bun run typecheck
  • targeted Biome checks
  • production library build
  • Zig 0.15.2 WASM build
  • patch applicability and clean submodule verification

The native sprite support increases ghostty-vt.wasm from 639,033 to 967,164 bytes.

Copilot AI review requested due to automatic review settings July 20, 2026 12:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Hona
Hona merged commit 0dcf958 into main Jul 20, 2026
Hona added a commit to anomalyco/opencode that referenced this pull request Jul 20, 2026
Includes the physical-pixel rendering and native Ghostty sprite work from anomalyco/ghostty-web#3.
avion23 pushed a commit to avion23/opencode that referenced this pull request Jul 20, 2026
Includes the physical-pixel rendering and native Ghostty sprite work from anomalyco/ghostty-web#3.
tobocop2 pushed a commit to tobocop2/opencode that referenced this pull request Jul 29, 2026
Includes the physical-pixel rendering and native Ghostty sprite work from anomalyco/ghostty-web#3.
3kaiu pushed a commit to 3kaiu/opencode-x that referenced this pull request Jul 31, 2026
Includes the physical-pixel rendering and native Ghostty sprite work from anomalyco/ghostty-web#3.
MarsQiu007 pushed a commit to MarsQiu007/openNovel that referenced this pull request Jul 31, 2026
Includes the physical-pixel rendering and native Ghostty sprite work from anomalyco/ghostty-web#3.
banlanzs pushed a commit to banlanzs/opencode that referenced this pull request Aug 6, 2026
Includes the physical-pixel rendering and native Ghostty sprite work from anomalyco/ghostty-web#3.
charlesverge pushed a commit to charlesverge/opencode that referenced this pull request Aug 11, 2026
Includes the physical-pixel rendering and native Ghostty sprite work from anomalyco/ghostty-web#3.
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
Includes the physical-pixel rendering and native Ghostty sprite work from anomalyco/ghostty-web#3.
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.

2 participants