-
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
Missing glyph substitution #10472
Comments
That is an excellent question. I believe we went with PolyTextOutW to reduce the number of times we needed to context-switch into kernel mode to one per buffer instead of one per line (?). @miniksa can keep me honest here, but he's out for a couple days. If it doesn't impact performance as much as it used to, this seems like a pretty easy win for a problem that's existed since time immemorial. 😄 |
As far as I can see, conhost.exe was already using PolyTextOutW back in Windows 7 (2009): dumpbin /imports:gdi32.dll conhost.exe
I've added this just before the loop: assert(_cPolyText == 1); and tried again, with cmd and other apps, outputting quite a few text in large and small blocks, using WriteConsoleW / WriteConsoleOutputW, but that assert never failed. It looks like there's not much to reduce in the first place, if anything :) I've also tried erasing and filling the whole viewport in a loop and haven't noticed any difference with the stock conhost - it flickers with visually the same frequency. Even the debug version performs acceptably. |
Wow, I found the actual changeset in Win7 that switched us to PolyTextOutW. Unfortunately, it switched us from something called
It looks like the decision to have a "fast path" for the console text pipeline to get out to GDI was made back in or before NT 3.5. Back then, and actually probably up until Windows 10, we did just send the entire console buffer to GDI every time it changed. Dirty region tracking (and therefore, not having |
This is probably one of those decisions we never revisited after being told that it was true when we inherited the code. 😄 |
And, surprisingly, glyph substitution worked before that changeset :) Apparently, even NtGdiConsoleTextOut had some extra magic which PolyTextOutW doesn't have. |
... shit. |
Yeah, we should definitely do this. Thanks @alabuzhev! |
Implementation of microsoft#10472. ExtTextOutW allows substitution of missing glyphs from other fonts.
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 substitute any 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 introduction of conhost.exe. Substitution worked in previous Windows versions, where internal NT interfaces were used. # Before the change: ![image](https://user-images.githubusercontent.com/11453922/122759189-93ff3900-d291-11eb-89a9-b1d47aa22ed9.png) # After the change: ![image](https://user-images.githubusercontent.com/11453922/122759316-b4c78e80-d291-11eb-87aa-7cdc2979ae28.png) Closes #10472
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
🎉This issue was addressed in #10478, which has now been successfully released as Handy links: |
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.It looks like
PolyTextOutW
doesn't try to substitute any 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).However, there are other APIs that perform such substitution, e.g.
ExtTextOutW
.Are there any reasons not to use them?
Proposed technical implementation details (optional)
A trivial replace
PolyTextOutW
->ExtTextOutW
already does the trick (and probably there are alternative / better methods as well):Before the change:
After the change:
It works as expected in other apps, including positioning, clipping, size, etc.:
So, any reason not to do that or something similar?
P.S. I'm aware that there's Windows Terminal, where it already works as expected. This is about conhost/OpenConsole.
The text was updated successfully, but these errors were encountered: