Skip to content

feat: powerline and block character rendering with visual tests#4

Merged
loeck merged 6 commits intomainfrom
slang25/powerline-render-tests
Apr 10, 2026
Merged

feat: powerline and block character rendering with visual tests#4
loeck merged 6 commits intomainfrom
slang25/powerline-render-tests

Conversation

@loeck
Copy link
Copy Markdown

@loeck loeck commented Apr 10, 2026

Summary

  • Adds pixel-perfect rendering for Powerline glyphs (U+E0B0–U+E0BF) and block-drawing characters (U+2580–U+259F) by drawing them as vector paths/rectangles, bypassing font rendering
  • Adds a headless visual regression test suite using Puppeteer with baseline screenshots
  • Migrates CI publishing from GitHub Packages to npm with OIDC trusted publishing

Changes

Port of coder/ghostty-web#128 with additional simplifications:

  • Cached font strings (4 variants) computed once instead of per-cell split/map/join
  • Codepoint range guards before block/powerline char dispatch (skip for normal ASCII)
  • Extracted drawHorizontalLine and strokeWithFillColor helpers (removed 3× and 4× duplicated canvas sequences)
  • Moved INVERSE color extraction inside the else branch (skip when colorOverride/isSelected)
  • Removed dead palette field and dangling orphaned JSDoc

Test plan

  • Visual render tests pass: bun test:render
  • Update baselines if needed: bun test:render:update
  • TypeScript type-check: bunx tsc --noEmit
  • Biome lint: bunx @biomejs/biome check lib/ demo/

slang25 and others added 6 commits February 25, 2026 00:08
- Implement renderBlockChar() for U+2580-U+259F block elements as pixel-perfect rectangles
- Implement renderPowerlineGlyph() for U+E0B0-U+E0BF glyphs as vector shapes
- Update font metrics to use fontBoundingBox for accurate cell height
- Add buildFontString() helper for proper font family quoting
- Add cursor style support from buffer and cursorAccent color rendering
- Add 15 visual regression tests covering text, colors, cursors, wide chars, and special glyphs
- Include headless Puppeteer test runner for CI/CD integration
- Add baseline PNG images for all tests passing

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Exit non-zero on startup failures in render test runner (P1)
- Wait for browser-side runAllTests() completion before reading canvases (P2)
- Use || instead of ?? for font metric fallbacks so 0 triggers fallback (P2)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix prettier formatting for render-test.html and correct import order
in render-test.ts to satisfy biome lint rules.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…path guards

- Cache all 4 font string variants (plain/bold/italic/boldItalic) at construction
  and on font changes instead of recomputing per cell via split/map/join
- Add codepoint range guards before renderBlockChar/renderPowerlineGlyph so
  normal ASCII cells skip both function calls entirely
- Extract drawHorizontalLine and strokeWithFillColor helpers to remove
  3× and 4× duplicated canvas stroke sequences
- Move INVERSE fg color extraction inside the else branch (skip when
  colorOverride or isSelected is set)
- Fix double `|| 32` codepoint fallback (was computed independently for
  char and codepoint)
- Remove dead palette field (written but never read)
- Remove dangling orphaned JSDoc comment
- Hoist render-test.ts contentTypes map to module scope
- Keep fontStrings cache, remove palette rebuild in constructor and setTheme
- Remove _theme/_theme getter (renamed to theme in this branch)
- Drop palette field brought back by auto-merge
- Use ?? instead of || for fontBoundingBox fallback (avoids 0-value edge case)
- Remove IIFE wrapper for linkRangeChanged comparison
- Capture fillColor at assignment instead of reading back from ctx.fillStyle
- Extract LINK_HOVER_COLOR constant (was hardcoded '#4A90E2' twice)
- Tighten powerline range guard to <= 0xe0b7 (matches actual handled range)
- Remove ctx param from strokeWithFillColor (always this.ctx)
- Merge hard/soft divider case pairs in renderPowerlineGlyph (shared path, branch on fill vs stroke)
- Remove dead Puppeteer auto-install catch block (puppeteer is in devDependencies)
- Simplify base64 data URL strip to split(',')[1]
- Add early-exit in calculateDiffPercent once threshold exceeded
@loeck loeck merged commit 010e10c into main Apr 10, 2026
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