Commit 2f64784
fix(renderer): align font metrics to device pixel boundaries to prevent seams (#6)
When devicePixelRatio is non-integer (e.g. 1.25, 1.5, 1.75 from browser
zoom or HiDPI displays), rounding cell width/height to the nearest CSS
pixel with Math.ceil() produces fractional *physical* pixel coordinates
at cell edges.
The canvas rasterizer antialiases clearRect/fillRect calls at those
sub-pixel boundaries. With alpha:true on the canvas (enabled in coder#93 for
transparent backgrounds), 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. The
+2/+1 paddings for glyph overflow stay in CSS units before the DPR
multiplication so they scale correctly.
Ports only the font-metrics subset of upstream PR coder#146 — the rest of
that PR bundles a substantial render-loop refactor (startRenderLoop →
scheduleRender) and several perf caches whose risk/benefit needs
separate evaluation against our current architecture.
Inspired-by: coder#146
Co-authored-by: tommyme <chris.b.you@qq.com>1 parent 453309b commit 2f64784
1 file changed
Lines changed: 19 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
56 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
201 | 200 | | |
202 | 201 | | |
203 | 202 | | |
204 | 203 | | |
205 | 204 | | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
210 | 221 | | |
211 | 222 | | |
212 | 223 | | |
| |||
0 commit comments