Repository navigation
Fix dynamic changing of font in Windows console on CJK codepages - #771
Merged
Jason Shirk (lzybkr) merged 4 commits intoOct 10, 2018
Merged
Jason Shirk (lzybkr) merged 4 commits into
Jason Shirk (lzybkr) merged 4 commits into
Conversation
Contributor
|
If PowerShell is not running in a console, this code probably won't work as expected - for example if we are running under ConPTY, so we should avoid checking the font in that case. I think you can check this easily enough by calling GetFileType on the file handle from STD_INPUT_HANDLE. If the return value is not FILE_TYPE_CHAR, then we can skip calling checking the font. |
Steve Lee (SteveL-MSFT)
force-pushed
the
outputencoding-rasterfont
branch
from
October 4, 2018 21:02
2f4e5fa to
f6906f7
Compare
Steve Lee (SteveL-MSFT)
force-pushed
the
outputencoding-rasterfont
branch
from
October 4, 2018 21:05
f6906f7 to
668b01d
Compare
|
|
||
| // If handle is not to a character device, we must be redirected: | ||
| int fileType = GetFileType(handle); | ||
| if ((fileType & FILE_TYPE_CHAR) != FILE_TYPE_CHAR) |
Member
Author
There was a problem hiding this comment.
Per the documentation, GetFileType() returns a single value and is not flags.
Jason Shirk (lzybkr)
approved these changes
Oct 10, 2018
This was referenced Dec 2, 2018
Open
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows, the outputencoding is tied to a codepage which is tied to a font. When using a CJK locale, the default is using a raster font that can render the CJK glyphs. Previously, PSReadLine 2.0.0 was manipulating the OutputEncoding to utf8 which resulted in a visible font change in the console and the resulting rendering in the screen buffer was not correct.
The fix is to detect that a raster font is being used and not change the output encoding. Also in cases where the output encoding is already utf8, there's no need to change it.