-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Replace PolyTextOutW with ExtTextOutW #10478
Conversation
Implementation of microsoft#10472. ExtTextOutW allows substitution of missing glyphs from other fonts.
@msftbot make sure @miniksa signs off on this |
Hello @DHowett! 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:
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". |
Notes for @miniksa: PerformanceI ran side-by-side WPR traces for PolyTextOut and ExtTextOutW with chafa and big.txt -- things that either require full screen invalidations or a lot of scrolling and region updates. big.txt would have been a "nothing but net" case for PolyTextOut, had we been blitting the entire buffer every time, as it requires rendering the entire screen in one color. PolyExtIt's interesting that we got nearly a thousand more samples in PaintBufferOutput for ExtTextOut in a similar time period (10.5 seconds - this captures 5 seconds of the tail end of a chafa animation plus three invocations of Anyway: Measurements taken on x64. Other architectures may have higher or lower system call overhead. Performance: I'm not worried about the impact on performance. Implementation Details
There's one critical difference: The user mode implementation of |
@msftbot make sure @miniksa signs off |
Hello @DHowett! 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:
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". |
sorry, had to re-trigger the bot 😄 Thanks for submitting this, @alabuzhev! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DHowett answered everything I was worried about. Good enough then. Let's do it!
@DHowett since you've already looked, is it really by design that PolyTextOutW doesn't substitute? I can't find such limitation in MSDN, it only says "To draw a single string of text, the application should call the ExtTextOut function", implying that the only difference in behaviour is single / multiline usage. Maybe it's also an accidental consequence of some changeset from decades ago? And if it's intentional it would probably make sense to reflect that explicitly on that page. |
I legitimately cannot figure out what's different about ETO when we call it versus when PolyTextOut calls it. Everything tells me that this should have just worked. . . |
@ MS people: Can you ask the GDI team why the PolyTextOut doesn't do this glyph substitution, while the ExtTextOut function does? And whether it would be possible to correct PolyTextOut to do so? |
Currently, when the user changes the console codepage (manually or via a script) the GDI engine tries to find and set the "best possible" font. The "best possible" here is charset-wise, it doesn't mean that the font is actually better or more eye-candy for the user. Example: - Open cmd - Set the font to Consolas - Enter `chcp 932` - Suddenly, a wild MS Gothic appears! This kind of makes sense (*"if I'm changing the codepage I probably want to see the national characters"*) but it doesn't happen anywhere else - all other apps just substitute the missing glyphs. After #10472 / #10478 this magic should finally work here as well. So, do we still need to change the whole font? Terminal doesn't do that after all. ## Validation Steps Performed Download [932.cmd.txt](https://github.com/microsoft/terminal/files/6697577/932.cmd.txt), rename to 932.cmd, run it, check if the output is still readable. Closes #10497
Yes, @HBelusca. I have done so this afternoon. This is what I got from the lead who currently owns GDI:
Uniscribe is one of the older Microsoft implementations from the Windows XP era for processing complex scripts and can be found here: https://docs.microsoft.com/windows/win32/intl/uniscribe Further on looking at the code with them: And then finally:
When asked about whether they would add it to However, it was also elaborated...
And when I asked if we should update the Remarks sections for these functions on docs.microsoft to add this additional information:
So I've volunteered to reach out to my contacts on the content publishing team and get ExtTextOutA, ExtTextOutW, PolyTextOutA, and PolyTextOutW updated with some additional remarks that clarify the difference in font fallback/Uniscribe support, the recommendation that |
Interesting, thanks @miniksa . But as I see in the documentation for As you told, and as the documentation suggests, |
It's possible. Don't get us wrong there. It's just that I don't think it's likely to happen. Significantly less likely to happen than me just updating the documentation to explain the way the world is and make recommendations on which path to use. If I had to hazard a guess (and this is a guess based on my personal experience, please don't misinterpret it as some declaration)...
I would guess that a combination of all of these factors go into the unlikelihood that I will have no problem in looking these sorts of things up for you now and in the future. And I also have no problem updating the official public documentation to help better inform you and others. |
🎉 Handy links: |
Replace PolyTextOutW with ExtTextOutW to allow substitution of missing
glyphs from other fonts.
Why not let Windows substitute the glyphs that are missing in the
current font? Currently the GDI renderer of conhost/OpenConsole uses
PolyTextOutW
for drawing.PolyTextOutW
doesn't try to substituteany missing glyphs, so the only way to see, say, Hiragana is to change
the whole font to something like MS Gothic (which is eye-bleeding, to
be honest).
A trivial replace
PolyTextOutW
->ExtTextOutW
does the trick.Switch to
PolyTextOutW
happened in Windows 7 along with introductionof conhost.exe. Substitution worked in previous Windows versions, where
internal NT interfaces were used.
Before the change:
After the change:
Closes #10472