terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Windows 10 1809/19H1/20H1 breaks Powershell's console settings. Keeps opening with raster fonts.

Open danielniccoli opened this issue 6 years ago • 94 comments

Windows 10 1809 breaks Powershell's console settings. Powershell keeps opening with raster fonts. You can change the settings and see the result, but when you open the settings again (with or without closing the powershell inbetween) the font has reset to raster fonts in size 12.

Edit: Upgraded from 1803. German Locale.

https://aka.ms/AA37kk1

danielniccoli avatar Oct 11 '18 19:10 danielniccoli

The same happens to me only when using the Consolas font. If I use anything else - Courier New, Lucida Console, etc. - the settings are retained.

winstliu avatar Oct 14 '18 21:10 winstliu

@50Wliu I can confirm that behaviour. Consolas resets to raster font. Lucida Console stays Lucida Console.

danielniccoli avatar Oct 15 '18 16:10 danielniccoli

I'm almost certain this has to do with the fact that the new version of PSReadline is using the UTF8 codepage for displaying it's prompt, and when it does that, the console tries to recalculate the font.

I thought we had some issues tracking this previously, but I can't seem to find them. @bitcrazed do you remember where they were? Or was it an internal mail thread with @lzybkr and @SteveL-MSFT?

zadjii-msft avatar Oct 15 '18 16:10 zadjii-msft

Can someone provide an exact repro? Like what font are you setting to the shortcut. What font is it being set to?

SteveL-MSFT avatar Oct 15 '18 16:10 SteveL-MSFT

  • Win-R and run powershell.
  • It starts with raster font.
  • Go into settings and set the font to Consolas. Click OK.
  • Consolas is being applied.
  • Close Powershell.
  • Reopen powershell like before.
  • Font is raster font again.
  • Go into default settings and set the font to Consolas. Click OK.
  • Close Powershell.
  • Reopen powershell like before.
  • Font is raster font again.

danielniccoli avatar Oct 15 '18 16:10 danielniccoli

I don't think this was even Powershell's fault. I have a note sitting around here somewhere that one of the most recent .NET Frameworks (4.7something) suddenly decides to use 65001 as the default code page for all apps and when that flips back and forth with other tools and codepages as they start and exit, we recalculate the font.

I have a bug on me to try to make that less painful, but it's really the sudden flipping between codepages that is making this be a problem.

miniksa avatar Oct 15 '18 16:10 miniksa

I can't reproduce this here. Both Windows PowerShell and Powershell both start up in the font I set.

doctordns avatar Oct 17 '18 09:10 doctordns

@Borkason Have you tried concfg clean https://github.com/lukesampson/concfg

cloudhan avatar Oct 17 '18 09:10 cloudhan

@borakson - what locale is your Windows configured to use?

bitcrazed avatar Oct 17 '18 20:10 bitcrazed

@bitcrazed I'm not @Borkason but since I'm experiencing this issue I'll answer as well.

My display language is Spanish (Spain), and so is my regional format. The language for programs that don't support Unicode is English (United States), and I have the beta checkbox selected for UTF-8 Unicode. (Hope that's what you're looking for...let me know if you were asking for something else)

winstliu avatar Oct 17 '18 21:10 winstliu

@bitcrazed German. And I upgraded from 1803. Forgot to meantion that.

danielniccoli avatar Oct 19 '18 11:10 danielniccoli

@doctordns which font?

danielniccoli avatar Oct 19 '18 11:10 danielniccoli

@doctordns which font?

I use Lucida Console (18 pt). But I've tested others and they too work after a restart of Windows PowerShell.

doctordns avatar Oct 19 '18 12:10 doctordns

The same happens to me only when using the Consolas font. If I use anything else - Courier New, Lucida Console, etc. - the settings are retained.

danielniccoli avatar Oct 19 '18 12:10 danielniccoli

This was likely fixed by @lzybkr's recent work: https://github.com/lzybkr/PSReadLine/issues/542

@Borkason & @doctordns - can you please confirm and close if fixed?

Thanks.

bitcrazed avatar Nov 12 '18 21:11 bitcrazed

@bitcrazed it looks like the issue you're referencing was fixed back in 2017 and as far as I can tell is included in the version of PSReadLine that 1809 ships with. Additionally, this issue is still occuring for me as of Windows Insiders build 18277.

winstliu avatar Nov 13 '18 04:11 winstliu

@bitcrazed That's one year older then the 1809 release. I wouldn't call that "recent".

And for me nothing changed. I'm on Windows 10 build 17763.107

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17763.1
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.1
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

But as @50Wliu already sayd, it's not even fixed in the current preview.

danielniccoli avatar Nov 15 '18 16:11 danielniccoli

Here is a link to the Feedback: https://aka.ms/AA37kk1

danielniccoli avatar Nov 15 '18 16:11 danielniccoli

@bitcrazed linked to the issue that caused the problem.

The fix is in this PR: https://github.com/lzybkr/PSReadLine/pull/771

lzybkr avatar Nov 15 '18 17:11 lzybkr

Fair enough. Is it known with what build the fix will ship?

danielniccoli avatar Nov 15 '18 17:11 danielniccoli

I'll try to release another beta to the PowerShell Gallery before the end of the year, but I don't know about Windows (I don't work on Windows).

@SteveL-MSFT owns the bits that ship in Windows, so maybe he can comment.

lzybkr avatar Nov 15 '18 18:11 lzybkr

Name Value


PSVersion 5.1.17763.134 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.17763.134 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

same here...ready to re-install windows, REALLY painful!

kid1412621 avatar Nov 29 '18 16:11 kid1412621

This problem seems links to fonts. I got the problem in Powershell with windows(cmd and Powershell core don't have this problem) when I set the font as 'Console', but when I change the font as 'Sarasa Mono SC', all work perfectly. I use 'Sarasa Mono SC' to show UTF-8 character, Windows 10 doesn't have a default font can show enough UTF-8 characters.

ghost avatar Dec 13 '18 02:12 ghost

Same here. Both my Surface & desktop PC.

xhxgit avatar Dec 26 '18 02:12 xhxgit

Strangely I think I am experiencing this same issue but from a different way. Whenever a subprocess is opened to run powershell.exe, the console font changes to raster from Consolas.

Example 1: I have vim running (WSL) and it runs a powershell sub command to get the system clipboard. Every time I run that command, it resets the console font to raster fonts.

Example 2: I have a shell script that runs powershell as a subprocess to get the system nameservers. It causes the same thing to happen to the console, a switch to raster fonts. Nothing is output to the console. Everything happens in the subprocess.

The really strange part is that if I run powershell manually from the console (WSL), then it's fine and the font does not change.

offero avatar Jan 13 '19 15:01 offero

@bitcrazed, @SteveL-MSFT, @lzybkr: I have a good minimal repro. This started happening right after I upgraded the machine to Windows 1809. I had the font and console CP set before, as below, to Consolas and 65001 respectively, and everything worked just fine. I work with UTF-8 files, so the CP 65001 has been essential to me. My locale is plain old en-US, English language Windows 10 x64 Pro, and the OEM CP is the default 437.

  1. Set the following registry keys (save as .reg and import). For some reason, it i important to change FontFamily, as the default may be different, and the font won't be applied.
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Console]
"FaceName"="Consolas"
"FontFamily"=dword:00000036
"FontSize"=dword:000f0000
"FontWeight"=dword:00000190
"CodePage"=dword:0000fde9
  1. Win+R cmd.exe ENTER. Console starts with the correct font and code page. Type chcp; it prints 65001 (if does not, run chcp 65001).
  2. in the console, type powershell -noprof ('-noprof' to confirm that the issue is not related to anything I load in my profile).

As PowerShell starts, the console font immediately changes to a raster font, and the window resizes to accommodate. The raster font selected is Terminal, and does not even even have WGL4 characters (no Cyrillic or Greek). So this is certainly a bug.

The behavior reproduces even if running a non-interactive command, so it's rather doubtful that the bug is related to PSReadLine:

powershell -noprof -nonint -command "echo foo"

Also, the console font changes similarly (essentially, the console opens in a raster font) if PowerShell is ran via a shortcut, or from the Win+R dialog, or by double-clicking in Explorer.

Also, some negatives. The font is not changed if either:

  • I run chcp 437 before invoking powershell from cmd.
  • The console font is set in the registry to "Lucida Console" (everything else stays same as above). That this font is somehow "special" has been already noted in the comments in this ticket.

The common theme in the comments in this issue has been, I believe, a non-US, European locale (German ans Spanish were mentioned). So i tried the following:

  1. Start cmd.exe
  2. Set console code page with chcp NNN (see below):
  3. Run powershell -noprof.
  • With NNN = 437, 1252, 1251, 1253, 850, 852, 869, 857, 737 - no font change
  • With NNN = 65001, 858, and non-WGL4 Hebrew 862, Arabic 864 - font does change.

What sets the CP 858 apart? My guess is this may be the key. The CP name is "OEM Multilingual Latin 1 + Euro symbol".

Also notable is that chcp 1255 and chcp 1266 (Hebrew and Arabic) change font to "Courier New" even in cmd.exe. So PowerShell may be only somehow more susceptible, not the main culprit?

Obligatory version info:

C:\Users\kkm> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17763.134
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.134
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Also, I should mention, although this is most likely irrelevant: I have a high-DPI display with the display scale set to 150%.

kkm000 avatar Jan 13 '19 22:01 kkm000

@kkm000 This was fixed in PSReadLine (https://github.com/lzybkr/PSReadLine/pull/771), but isn't in the build of Windows you are using, although the fix was checked into a newer build of Windows. I believe the newest public Beta of PSReadLine has the fix, so you can install it in Windows PowerShell using:

install-module psreadline -AllowPrerelease -Repository PSGallery -Force
# restart PowerShell to load the new one

If it complains that -AllowPrerelease isn't found, you'll have to update PowerShellGet:

install-module powershellget -Scope CurrentUser -Repository psgallery -Force -AllowClobber
# restart PowerShell to load the new one

SteveL-MSFT avatar Jan 15 '19 01:01 SteveL-MSFT

although the fix was checked into a newer build of Windows.

Does this mean that the fix will be coming to a future (19H1) Insiders release?

winstliu avatar Jan 15 '19 03:01 winstliu

@50Wliu yes

SteveL-MSFT avatar Jan 15 '19 18:01 SteveL-MSFT

@SteveL-MSFT i have the same version like @kkm000 , i ran you commands and not work for me, i miss something?

sl1pkn07 avatar Jan 16 '19 17:01 sl1pkn07