-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Handle things above U+FFFF in GDI renderer #10477
Comments
This looks awesome! But it's also a bit scary for me personally. Your other issue is quite easy for me to understand, but the changes you suggest here would add surrogate support, despite us not properly supporting surrogate pairs anywhere else yet... I'm not 100% sure if your change would work in all corner cases. But granted, I'm relatively new in these parts of our codebase and other maintainers of this project are a better fit to review the changes you suggest. |
Surrogates definitely need a little more love on the text buffer side, for sure. Right now, they (perhaps puzzlingly) only work for double-width glyphs because technically they're being stored directly int eh buffer. This complicates a number of things:
As opposed to #10472 (which I would love to see a pull request for! for attribution's sake 😄) I'm more hesitant on this one. It will make things look like they're working more correctly than they actually are, and that may get us into more compliance trouble than simply rejecting them would. |
(We're working on surrogate pairs et al over in #8000) |
@lhecker I'd say you do support surrogates more or less acceptably already, except for this rendering gap. This already works in Windows Terminal and, philosophically, as a middleman you don't have to do much at all:
Everything else is up to the client. Here's an example of an app working with surrogate pairs in a patched OpenConsole: As you can see, the cursor occupies two cells already, everything is sized, clipped and positioned as expected. Indeed, it's a quite complex subject and there are known issues with surrogates that logically occupy one cell etc., but I'd say that a partially garbled output is still better than a bunch of perfectly drawn "�". |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I'm gonna say if this just so happens to work for the DX renderer today, and a trivial change will make it work in GDI, then lets go for it. It might not be technically correct in the buffer, but hey, it's just as technically incorrect in Terminal as in conhost, and Terminal renders it fine. @miniksa for a veto vote though. |
I'm good with @alabuzhev's proposed code. As far as I can recall... the substitution was based on it not working with I concur with the argument that it is better than the existing... anything is better than a substitution glyph... and much of the code can handle basic surrogates already. Sure there will be rough edges... but its not worse than today. And again... I think real characters over replacements isn't going to stop an assembly line. :P |
Thanks, I'll turn it into a PR then. |
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Implementation of #10477 - handle surrogate pairs in GDI renderer. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [ ] Closes #10477 * [x] CLA signed. * [ ] Tests added/passed * [ ] Documentation updated. * [ ] Schema updated. * [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #10477 <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments ### Why not let Windows draw surrogate pairs? It can do that. Basically, the comment says everything: https://github.com/microsoft/terminal/blob/c90de692509b074bfde191910d67154cfe389911/src/renderer/gdi/paint.cpp#L346-L347 However, handling things above U+FFFF doesn't really require extra effort. It's enough to: - Put *all* characters to the output buffer - Set the first width to cluster width and the rest to 0 - Sit back and relax while Windows does the rest <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed ```CMD @echo off chcp 65001 echo 𠜎𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎 echo 👨👩👧👦 ``` Save this as a UTF-8 cmd file and run. ### Before the change ![image](https://user-images.githubusercontent.com/11453922/122832196-ed438880-d2e2-11eb-93dd-931954efedbf.png) ### After the change ![image](https://user-images.githubusercontent.com/11453922/122832217-f2a0d300-d2e2-11eb-99f0-e129e5544667.png) An example of a third party app working with surrogate pairs in a patched OpenConsole: ![image](https://user-images.githubusercontent.com/11453922/122838225-837cac00-d2ed-11eb-8faf-dbeb52f77916.png) As discussed, this change doesn't claim to be the full support for surrogate pairs (there are still corner cases possible), but brings it on par with Terminal with minimal effort.
🎉This issue was addressed in #10580, which has now been successfully released as Handy links: |
Why not let Windows draw surrogate pairs? It can do that.
Basically, the comment says everything:
terminal/src/renderer/gdi/paint.cpp
Lines 346 to 347 in c90de69
However, handling things above U+FFFF doesn't really require extra effort.
Proposed technical implementation details (optional)
Testing
Save this as a UTF-8 cmd file and run.
Before the change
After the change
The text was updated successfully, but these errors were encountered: