Skip to content

[CTX-0237] fix(render): tall-glyph clipping + blur (measured baseline, 10x22 cell) - #413

Merged
Xuepoo merged 2 commits into
mainfrom
carryctx/ctx-0237
Sep 8, 2026
Merged

Xuepoo merged 2 commits into
mainfrom
carryctx/ctx-0237

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

What & why

Tall glyphs (block elements, powerline separators, nerd icons in starship)
lost their tops: the pen sat on a fixed 3/4-cell baseline inside a 9x19 cell
while JetBrainsMono Nerd Font 12pt rasters need advance 10 / line 22.
Live crossfont probe: avg_adv=10 line_h=22 descent=-5; full block
top=17 h=22 landed at dest_y=-3 (3px clipped by neighbor-row repaint).
Closes #412.

Priority: P1 | Area: render | Labels: fix,area:render,P1 | Milestone: v0.1.0 | RFC: OQ-xxx | Task: CTX-0237

Changes

  • bitty-render/src/glyph.rs: new FontMetrics (advance/line/descent,
    upstream sign) with is_usable gate; GlyphRasterizer::font_metrics
    default returns Ok(None) so existing implementors keep compiling.
  • bitty-render/src/crossfont_backend.rs: implements font_metrics from
    upstream face metrics; rejects bad sizes / stale handles.
  • bitty-render/src/fallback.rs: forwards font_metrics to the primary face.
  • bitty-render/src/cache.rs: rasterizer() borrow for best-effort measurement.
  • bitty-render/src/grid.rs: resolve_baseline_offset (measured
    line+descent, clamped into the cell; legacy 3/4 fallback); GridRenderer
    stores baseline_offset, adopts it in new/apply_dpi_scale, uses it in
    both emit paths. Full bitmaps still emit at baseline - top (overdraw
    permitted, never cell-clipped).
  • bitty-config/src/types.rs: defaults line_height 1.2 -> 1.375,
    letter_spacing 1.0 -> 2.0; live effective cell 9x19 -> 10x22 (measured
    raster truth; in-font tall glyphs fit with zero overhang).
  • bitty-app/src/main.rs: scope-adjacent mechanical update only — mapped-cell
    doc/expectation 9x19 -> 10x22 (no logic change; RuntimeConfig 9x19 headless
    defaults intentionally untouched).

Testing

  • cargo fmt --all -- --check clean
  • RUSTFLAGS="-D warnings" cargo clippy -p bitty-render -p bitty-config -p bitty-app -p bitty-runtime --all-targets clean (1 pre-existing escaped-newline notice, untouched region)
  • cargo test --workspace --all-targets --locked: 2339 passed, 0 failed
  • cargo check --target x86_64-pc-windows-gnu --workspace --all-targets clean
  • actionlint -color clean; act -n (ci.yml) clean
  • Headless crossfont probe (evidence: recording/ctx-0237/probe-output.txt)
  • 9 new tests: metric baseline resolution/clamp/fallback, tall-glyph
    zero-overhang fit, over-tall overhang permission, DPI re-resolve,
    metrics usability gate, default no-measurement, crossfont bad-size rejection
  • Live grim before/after on ws4: SKIPPED (headless implementer; needs
    focus-verified seat gestures per phantom-input rule) — commander to verify
  • Note: tests::demo_pump_opt_in_delivers_greeting flaked 2x during gating
    (yield-only pump-thread race); known pre-existing flake per PX-1210,
    unrelated to this diff; full workspace suite green.

Checklist

  • No new clipping: software path clips surface-only, GPU path has no
    per-tile scissor (CTX-0234); diff adds no scissor/clip
  • No secrets or local paths committed (recording/ctx-0237/ left untracked;
    temporary probe moved to .trash/bitty/CTX-0237/)
  • Scope-adjacent bitty-app test/doc touch flagged for reviewer (mechanical only)

Xuepoo and others added 2 commits September 8, 2026 14:20
…glyph clipping

Tall glyphs (block elements, powerline separators, nerd icons) lost their tops because the pen sat on a fixed 3/4-cell baseline inside a 9x19 cell while JetBrainsMono Nerd Font 12pt rasters need advance 10 / line 22 (live crossfont probe: avg_adv=10 line_h=22 descent=-5; full block top=17 h=22 landed at dest_y=-3, 3px clipped).

GridRenderer now resolves the baseline from measured face metrics (line+descent, clamped, legacy 3/4 fallback); GlyphRasterizer gains an optional font_metrics hook (crossfont + fallback implement it); defaults move to letter-spacing +2 / line-height 1.375 so the live cell is 10x22 and measured tall glyphs fit with zero overhang. Over-tall outliers keep the permitted overdraw path (no cell clipping, both present paths already clip surface-only). Blur audit: raster size tracks DPI with cache invalidation (NDC ~1.0), integer pen placement, 10px cell matches the 10px raster advance.
@Xuepoo Xuepoo added fix Bug fix area:render Area: rendering labels Sep 8, 2026
@Xuepoo Xuepoo added this to the v0.1.0 milestone Sep 8, 2026
@Xuepoo Xuepoo added the P1 Priority: high label Sep 8, 2026
@Xuepoo
Xuepoo merged commit 308687d into main Sep 8, 2026
10 checks passed
@Xuepoo
Xuepoo deleted the carryctx/ctx-0237 branch September 8, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:render Area: rendering fix Bug fix P1 Priority: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CTX-0237] Glyph clipping + blur on tall glyphs (starship/powerline/nerd: top cut off)

1 participant