Commit 3cd71b0
committed
fix(terminal): render terminal canvas at correct DPR when webview is zoomed
Tauri/Electron native zoom does not update window.devicePixelRatio,
causing the xterm.js WebGL canvas to render at 1x resolution regardless
of zoom level. The native zoom then upscales the bitmap, producing
blurry terminal text at zoom levels above 100%.
Fix by overriding the devicePixelRatio getter in zoomWebView() to
reflect the effective DPR (baseDPR * zoomFactor). The terminal detects
DPR changes during fit() and calls clearTextureAtlas() to rebuild
glyphs at the new resolution. Also guards _cropDataUrlToRect to use
the original base DPR so screenshot cropping is unaffected.1 parent fe46411 commit 3cd71b0
2 files changed
Lines changed: 44 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
| |||
144 | 146 | | |
145 | 147 | | |
146 | 148 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
| 149 | + | |
152 | 150 | | |
153 | 151 | | |
154 | 152 | | |
| |||
270 | 268 | | |
271 | 269 | | |
272 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
273 | 287 | | |
274 | 288 | | |
275 | 289 | | |
| |||
288 | 302 | | |
289 | 303 | | |
290 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
291 | 314 | | |
292 | 315 | | |
293 | 316 | | |
| |||
416 | 439 | | |
417 | 440 | | |
418 | 441 | | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
419 | 446 | | |
420 | 447 | | |
421 | 448 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
| 206 | + | |
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| |||
859 | 859 | | |
860 | 860 | | |
861 | 861 | | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
862 | 873 | | |
863 | 874 | | |
864 | 875 | | |
| |||
0 commit comments