fix(renderer): align font metrics to device pixel boundaries to prevent seams#146
Open
tommyme wants to merge 1 commit intocoder:mainfrom
Open
fix(renderer): align font metrics to device pixel boundaries to prevent seams#146tommyme wants to merge 1 commit intocoder:mainfrom
tommyme wants to merge 1 commit intocoder:mainfrom
Conversation
…nt seams When devicePixelRatio is non-integer (e.g. 1.25/1.5/1.75 from browser zoom), rounding cell width/height to the nearest CSS pixel produces fractional physical pixel coordinates at cell edges. The canvas rasterizer antialiases clearRect/fillRect at those sub-pixel boundaries, and with alpha:true the resulting partially-transparent edge pixels composite against the page background and appear as thin black seams between rows and columns. Fix by rounding up to the nearest *device* pixel instead: Math.ceil(value * dpr) / dpr This guarantees cell boundaries always fall on exact physical pixel boundaries regardless of zoom level or monitor DPR. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
devicePixelRatiois non-integer (e.g. 1.25, 1.5, 1.75 from browser zoom or high-DPI displays), rounding cellwidth/heightto the nearest CSS pixel withMath.ceil()produces fractional physical pixel coordinates at cell edges.The canvas rasterizer antialiases
clearRect/fillRectcalls at those sub-pixel boundaries. Withalpha: trueon the canvas, the resulting partially-transparent edge pixels composite against the page background and appear as thin black seams between rows and columns.Fix
Round up to the nearest device pixel instead of CSS pixel:
This guarantees cell boundaries always fall on exact physical pixel boundaries regardless of zoom level or monitor DPR.
🤖 Generated with Claude Code