Skip to content

[WebGL] Round fractional character dimensions to the nearest device pixel - #6300

Open
nicolashenry wants to merge 2 commits into
xtermjs:masterfrom
nicolashenry:feature/round-char-dimensions
Open

nicolashenry wants to merge 2 commits into
xtermjs:masterfrom
nicolashenry:feature/round-char-dimensions

Conversation

@nicolashenry

Copy link
Copy Markdown

Fixes #6264.

The WebGL renderer floors fractional character widths and ceils character heights when converting CSS dimensions to device pixels. At a device pixel ratio of 1, a measured width of 6.82 CSS pixels becomes 6 device pixels instead of 7.

Round both measured character dimensions to the nearest device pixel.

Adds a regression test using fractional character measurements to verify that width 6.5 rounds to 7 and height 10.4 rounds to 10.

Tests: the new Chromium regression test passes. The full WebGL integration file had 61 passed, 9 skipped, and 1 failure: #4736 (inactive selection background rendered white instead of red).

…arity

test(webgl): add test for rounding fractional character dimensions
Copilot AI balanced review requested due to automatic review settings November 6, 2026 22:10

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.

🟢 Approval recommended

No active review issues are reported for the change to round WebGL character dimensions to the nearest device pixel.

No open issues 🎉

What changed in this PR

This PR addresses #6264 by rounding WebGL character dimensions to the nearest device pixel, avoiding the narrower cells caused by flooring fractional widths.

Changes:

  • Uses Math.round for both measured character width and height.
  • Adds a regression test verifying that, at DPR 1, width 6.5 becomes 7 and height 10.4 becomes 10.
File Description
addons/​addon-webgl/​test/​WebglRenderer.test.ts Adds fractional-dimension rounding coverage with measurement restoration and page cleanup.
addons/​addon-webgl/​src/​WebglRenderer.ts Replaces width flooring and height ceiling with nearest-pixel rounding.

Review effort: Balanced

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.

[WebGL] Fractional character width is floored to fewer device pixels

2 participants