Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
20 commits merged into from
Feb 21, 2020

Conversation

miniksa
Copy link
Member

@miniksa miniksa commented Feb 20, 2020

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

@miniksa miniksa self-assigned this Feb 20, 2020
@miniksa miniksa added Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. labels Feb 20, 2020
@DHowett-MSFT
Copy link
Contributor

I've kicked the x64 build to restart only that leg.

@miniksa miniksa added the AutoMerge Marked for automatic merge by the bot when requirements are met label Feb 21, 2020
@ghost
Copy link

ghost commented Feb 21, 2020

Hello @miniksa!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

Do note that I've been instructed to only help merge pull requests of this repository that have been opened for at least 8 hours, a condition that will be fulfilled in about 5 hours 18 minutes. No worries though, I will be back when the time is right! 😉

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@miniksa
Copy link
Member Author

miniksa commented Feb 21, 2020

@msftbot merge in -1 minutes

@ghost
Copy link

ghost commented Feb 21, 2020

Hello @miniksa!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I won't merge this pull request until after the UTC date Fri, 21 Feb 2020 00:23:46 GMT, which is in 1 minute

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

@ghost ghost merged commit 4420950 into master Feb 21, 2020
@ghost ghost deleted the dev/miniksa/draw2 branch February 21, 2020 00:24
DHowett-MSFT pushed a commit that referenced this pull request Feb 28, 2020
…Correct PTY rendering on trailing half of fullwidth glyphs (#4668)"

This reverts commit 4420950.
ghost pushed a commit that referenced this pull request Dec 4, 2020
When the renderer is called on to render part of a line starting halfway
through a DBCS character (as can occur in conhost when the viewport is
offset horizontally), it could result in the character not being
displayed, and/or with following the characters drawn in the wrong
place. This PR is an attempt to fix those problems. 

The original code for handling the trailing half of fullwidth glyphs was
introduced in PR #4668 to fix issue #2191.

When the content being rendered starts with the trailing half of a DBCS
character, the renderer tries to move the `screenPoint` back a position,
so it can instead render the full character, but instructing the render
engine to trim off the left half of it.

If the X position was already in column 0, though, it would instead move
forward one position, intending to skip that character. At best this
would mean the half character wouldn't be rendered, but since the
iterator wasn't incremented correctly, it actually just ended up
rendering the character in the wrong place.

The fix for this was simply to drop the check for the X position being
in column 0, and allow it go negative. The rendering engine would then
just start rendering the character partially off screen, and only the
second half of it would be displayed, which is exactly what is needed.

The second problem was that the code incrementing the iterator was using
the `columnCount` variable rather than the `it->Columns()` value for the
current position. When dealing with the trailing half of a DBCS
character, the `columnCount` is 2, but the `Columns()` value is 1. If
you use the former rather than the later, then the renderer may skip the
following character.

## Validation Steps Performed
I've developed a more easily reproducible version of the test case
described in #8390, and confirmed that the problem no longer occurs when
this PR is applied.

I've also manually confirmed that the problem described in #2191 that
was fixed by PR #4668 is still working correctly now.

Closes #8390
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Chinese characters are not rendering correctly if I type above them.
3 participants