Commit 7cedf85
Center glyphs vertically when lineSpacing > 1
lineSpacing scales the cell height in computeFontDimensions(), but the
baseline stayed pinned at ceil(descent + leading) from the cell bottom,
so all the added height piled up above the text and lines looked
bottom-heavy at larger values (1.4-1.6).
Introduce a single shared TerminalView.baselineOffset that splits the
extra height evenly above and below the glyph (the half-leading model
iTerm2 and WezTerm use), and make every place that previously computed
its own ceil(descent + leading) read it instead:
- drawTerminalContents (CoreGraphics text path)
- CaretView.drawCursor, so the glyph drawn inside the caret stays on
the same baseline as the text under it
- MetalTerminalRenderer buildDrawData and buildCursorDrawData (which no
longer takes lineDescent/lineLeading parameters)
- glyphSlotFit's vertical-centering math for scaled wide glyphs, whose
dy is applied on top of the draw-time offset and therefore has to
agree with it
At lineSpacing == 1.0 the extra is zero and baselineOffset reduces to
the classic ceil(descent + leading): offscreen renders of upstream and
this branch are byte-identical. At 1.6 the caret glyph, CG text, and
DECDHL double-height rows were verified against offscreen renders.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 58915b1 commit 7cedf85
3 files changed
Lines changed: 30 additions & 16 deletions
File tree
- Sources/SwiftTerm/Apple
- Metal
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
| 127 | + | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
| |||
277 | 279 | | |
278 | 280 | | |
279 | 281 | | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
280 | 301 | | |
281 | 302 | | |
282 | 303 | | |
| |||
314 | 335 | | |
315 | 336 | | |
316 | 337 | | |
| 338 | + | |
| 339 | + | |
317 | 340 | | |
318 | 341 | | |
319 | | - | |
320 | 342 | | |
321 | | - | |
| 343 | + | |
322 | 344 | | |
323 | 345 | | |
324 | 346 | | |
| |||
1254 | 1276 | | |
1255 | 1277 | | |
1256 | 1278 | | |
1257 | | - | |
1258 | | - | |
1259 | | - | |
| 1279 | + | |
1260 | 1280 | | |
1261 | 1281 | | |
1262 | 1282 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | | - | |
44 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
607 | 607 | | |
608 | 608 | | |
609 | 609 | | |
610 | | - | |
611 | | - | |
612 | | - | |
| 610 | + | |
613 | 611 | | |
614 | 612 | | |
615 | 613 | | |
| |||
787 | 785 | | |
788 | 786 | | |
789 | 787 | | |
790 | | - | |
791 | | - | |
792 | 788 | | |
793 | 789 | | |
794 | 790 | | |
| |||
2124 | 2120 | | |
2125 | 2121 | | |
2126 | 2122 | | |
2127 | | - | |
2128 | | - | |
2129 | 2123 | | |
2130 | 2124 | | |
2131 | 2125 | | |
| |||
2236 | 2230 | | |
2237 | 2231 | | |
2238 | 2232 | | |
2239 | | - | |
| 2233 | + | |
2240 | 2234 | | |
2241 | 2235 | | |
2242 | 2236 | | |
| |||
0 commit comments