[PR #4668] [MERGED] Restrict DX run height adjustment to only relevant glyph AND Correct PTY rendering on trailing half of fullwidth glyphs #25885

Open
opened 2026-01-31 09:12:25 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/4668
Author: @miniksa
Created: 2/20/2020
Status: Merged
Merged: 2/21/2020
Merged by: @undefined

Base: masterHead: dev/miniksa/draw2


📝 Commits (10+)

  • b032e7e Add tracelogging provider to DX and add something that prints out what portions of the screen are considered invalid.
  • 031e558 Fix tracelogging multiple registration.
  • 22899a0 stop cursor blinking to aid debugging.
  • a63f46b Correct for scaling down individual glyphs. Since a scale factor applies to an entire run, break the one glyph into its own run before applying scale down.
  • ce3dfcc Make the invalid printout give the character counts as well as pixel counts to save mental effort.
  • 26aaab7 Comment like a mad man.
  • b09946c Restoring trimleft compensation appropriately prevents the half characters from getting struck over the PTY.
  • 4cf7394 Revert "stop cursor blinking to aid debugging."
  • bc16f70 Add actual work item for the todo I left behind.
  • 0cfb256 add comment to extracted _OrderRuns method

📊 Changes

12 files changed (+505 additions, -86 deletions)

View changed files

📝 OpenConsole.sln (+29 -0)
📝 src/renderer/base/renderer.cpp (+33 -3)
📝 src/renderer/dx/CustomTextLayout.cpp (+228 -80)
📝 src/renderer/dx/CustomTextLayout.h (+21 -0)
📝 src/renderer/dx/DxRenderer.cpp (+1 -1)
📝 src/renderer/dx/dirs (+2 -1)
src/renderer/dx/ut_dx/CustomTextLayoutTests.cpp (+100 -0)
src/renderer/dx/ut_dx/DefaultResource.rc (+12 -0)
src/renderer/dx/ut_dx/Dx.Unit.Tests.vcxproj (+40 -0)
src/renderer/dx/ut_dx/product.pbxproj (+4 -0)
src/renderer/dx/ut_dx/sources (+34 -0)
📝 src/renderer/vt/tracing.cpp (+1 -1)

📄 Description

Summary of the Pull Request

  • Height adjustment of a glyph is now restricted to itself in the DX
    renderer instead of applying to the entire run
  • ConPTY compensates for drawing the right half of a fullwidth
    character. The entire render base has this behavior restored now as
    well.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Two issues:

  1. On the DirectX renderer side, when confronted with shrinking a glyph,
    the correction code would apply the shrunken size to the entire run, not
    just the potentially individual glyph that needed to be reduced in size.
    Unfortunately while adjusting the horizontal X width can be done for
    each glyph in a run, the vertical Y height has to be adjusted for an
    entire run. So the solution here was to split the individual glyph
    needing shrinking out of the run into its own run so it can be shrunk.
  2. On the ConPTY side, there was a long standing TODO that was never
    completed to deal with a request to draw only the right half of a
    two-column character. This meant that when encountering a request for
    the right half only, we would transmit the entire full character to be
    drawn, left and right halves, struck over the right half position. Now
    we correct the cursor back a position (if space) and draw it out so the
    right half is struck over where we believe the right half should be (and
    the left half is updated as well as a consequence, which should be OK.)

The reason this happens right now is because despite VIM only updating
two cells in the buffer, the differential drawing calculation in the
ConPTY is very simplistic and intersects only rectangles. This means
from the top left most character drawn down to the row/col cursor count
indicator in vim's modeline are redrawn with each character typed. This
catches the line below the edited line in the typing and refreshes it.
But incorrectly.

We need to address making ConPTY smarter about what it draws
incrementally as it's clearly way too chatty. But I plan to do that with
some of the structures I will be creating to solve #778.

Validation Steps Performed

  • Ran the scenario listed in #2191 in vim in the Terminal
  • Added unit tests similar to examples given around glyph/text mapping
    in runs from Microsoft community page

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/4668 **Author:** [@miniksa](https://github.com/miniksa) **Created:** 2/20/2020 **Status:** ✅ Merged **Merged:** 2/21/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/miniksa/draw2` --- ### 📝 Commits (10+) - [`b032e7e`](https://github.com/microsoft/terminal/commit/b032e7ee591c96503043f99cd4d0b787c693c6d7) Add tracelogging provider to DX and add something that prints out what portions of the screen are considered invalid. - [`031e558`](https://github.com/microsoft/terminal/commit/031e558c09b49e323a75c5ef56e287a860866aaa) Fix tracelogging multiple registration. - [`22899a0`](https://github.com/microsoft/terminal/commit/22899a0efc1882c6b70cf0a662df54e0489bc347) stop cursor blinking to aid debugging. - [`a63f46b`](https://github.com/microsoft/terminal/commit/a63f46b5cb3c0feedcdba74ebc2cd5c8262196f5) Correct for scaling down individual glyphs. Since a scale factor applies to an entire run, break the one glyph into its own run before applying scale down. - [`ce3dfcc`](https://github.com/microsoft/terminal/commit/ce3dfcc8fbea68e48cb2d39d0ca1c47f286237dc) Make the invalid printout give the character counts as well as pixel counts to save mental effort. - [`26aaab7`](https://github.com/microsoft/terminal/commit/26aaab79ddeee1bd3e7a9600f8c4e25a79e42852) Comment like a mad man. - [`b09946c`](https://github.com/microsoft/terminal/commit/b09946c3e1eea825313656705d3a41cbbf0612b8) Restoring trimleft compensation appropriately prevents the half characters from getting struck over the PTY. - [`4cf7394`](https://github.com/microsoft/terminal/commit/4cf7394fbf1197a42b6c51cd3a51dccae081142f) Revert "stop cursor blinking to aid debugging." - [`bc16f70`](https://github.com/microsoft/terminal/commit/bc16f700b60ef377a4130bb625c5a1a3bc52007e) Add actual work item for the todo I left behind. - [`0cfb256`](https://github.com/microsoft/terminal/commit/0cfb2567d0db86d53ccab05055ee8cdc6593bc8a) add comment to extracted _OrderRuns method ### 📊 Changes **12 files changed** (+505 additions, -86 deletions) <details> <summary>View changed files</summary> 📝 `OpenConsole.sln` (+29 -0) 📝 `src/renderer/base/renderer.cpp` (+33 -3) 📝 `src/renderer/dx/CustomTextLayout.cpp` (+228 -80) 📝 `src/renderer/dx/CustomTextLayout.h` (+21 -0) 📝 `src/renderer/dx/DxRenderer.cpp` (+1 -1) 📝 `src/renderer/dx/dirs` (+2 -1) ➕ `src/renderer/dx/ut_dx/CustomTextLayoutTests.cpp` (+100 -0) ➕ `src/renderer/dx/ut_dx/DefaultResource.rc` (+12 -0) ➕ `src/renderer/dx/ut_dx/Dx.Unit.Tests.vcxproj` (+40 -0) ➕ `src/renderer/dx/ut_dx/product.pbxproj` (+4 -0) ➕ `src/renderer/dx/ut_dx/sources` (+34 -0) 📝 `src/renderer/vt/tracing.cpp` (+1 -1) </details> ### 📄 Description ## Summary of the Pull Request - Height adjustment of a glyph is now restricted to itself in the DX renderer instead of applying to the entire run - ConPTY compensates for drawing the right half of a fullwidth character. The entire render base has this behavior restored now as well. ## PR Checklist * [x] Closes #2191 * [x] I work here * [x] Tests added/passed * [x] No doc * [x] Am core contributor. ## Detailed Description of the Pull Request / Additional comments Two issues: 1. On the DirectX renderer side, when confronted with shrinking a glyph, the correction code would apply the shrunken size to the entire run, not just the potentially individual glyph that needed to be reduced in size. Unfortunately while adjusting the horizontal X width can be done for each glyph in a run, the vertical Y height has to be adjusted for an entire run. So the solution here was to split the individual glyph needing shrinking out of the run into its own run so it can be shrunk. 2. On the ConPTY side, there was a long standing TODO that was never completed to deal with a request to draw only the right half of a two-column character. This meant that when encountering a request for the right half only, we would transmit the entire full character to be drawn, left and right halves, struck over the right half position. Now we correct the cursor back a position (if space) and draw it out so the right half is struck over where we believe the right half should be (and the left half is updated as well as a consequence, which should be OK.) The reason this happens right now is because despite VIM only updating two cells in the buffer, the differential drawing calculation in the ConPTY is very simplistic and intersects only rectangles. This means from the top left most character drawn down to the row/col cursor count indicator in vim's modeline are redrawn with each character typed. This catches the line below the edited line in the typing and refreshes it. But incorrectly. We need to address making ConPTY smarter about what it draws incrementally as it's clearly way too chatty. But I plan to do that with some of the structures I will be creating to solve #778. ## Validation Steps Performed - Ran the scenario listed in #2191 in vim in the Terminal - Added unit tests similar to examples given around glyph/text mapping in runs from Microsoft community page --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:12:25 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#25885