Font in WSL Console window changes to Raster Fonts when Running a powershell.exe command with Consolas font
jay-tuckey opened this issue ยท 12 comments
This was discovered from the issue here: microsoft/WSL#2050
The issue is that if I'm using WSL, and execute a command like powershell.exe -command 'Write-output hi' | cat
the console font changes to Raster fonts and it resizes the console.
Windows version:
C:\>ver
Microsoft Windows [Version 10.0.17763.292]
Steps to reproduce
- Delete
HKEY_CURRENT_USER\Console
to reset console to all default settings - Run ubuntu console. You should now have these font settings:
- Execute
powershell.exe -command 'Write-output hi'
- no font change, and it correctly echo 'hi' to the command line:
- Execute
powershell.exe -command 'Write-output hi' | cat
- font changes to Raster Fonts, and windows resizes to match new font:
Some notes on the behaviour that we discovered in the previous issue:
- Doesn't occur in wsltty
- Doesn't occur if you are using using
Lucida Console
as your font. - Confirmed to also occur on build 18329
Let me know if you need any further debugging or testing.
This looks like #280.
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.
(~miniksa)
As a side effect of WSL switching to ConPTY for interop hosting, this should technically be fixed for this particular use case ...
This looks like #280.
I'll buy that it's a dupe for a dollar. I think I see what happened there now. Thanks Dustin.
FWIW, my PSVersion is 5.1.18329.1
and can still reproduce the issue. The purported fix to PSReadline was done back in the October 2018 timeframe. I did some PS rain dancing of questionable merit but it didn't take. My PSReadLine version is 2.0.0. DotNetFrameworkVersion claims 4.6.1 (contrast 4.7something).
But for giggles I installed PowerShell v6.2.0-preview.4 and sure enough it works with Consolas through WSL interop.
$ /mnt/c/Program\ Files/PowerShell/6-preview/pwsh.exe -command 'Write-output hi' | cat
hi
Still, it sure seems like something is rotten in Denmark. I can see Windows Console behaving badly if Jay's post was strewn with Chinese Heiti, but it isn't. Everything here is in 'merican. wsltty
works alright, and they use an old-school hidden Console Window not the new fancy-schmancy ConPTY. Academic I guess. Grateful to see it all improving. Still.....
I was looking for a workaround when using $(command-that-invokes-powershell)
in a script on WSL. After a horrible hack involving wscript.exe, I've now written a tiny C++ helper I called keepfont.exe that calls CreateProcess with CREATE_NEW_CONSOLE and a STARTUPINFO that shares the stdin/stdout/stderr handles and hides the resulting window. Then my script uses $(keepfont.exe command-that-invokes-powershell)
instead.
It's not quite perfect, but now my script works and my font stays, at least on stock 1809. I hope this idea helps someone else keep their sanity too!
This is still broken for me on the latest fast ring. Any word on this? It totally breaks my Emacs workflow.
Still the issue here. Did assign a, variable=powershell.exe -File "somescript.ps1"
then the bug occurs. It's a shame
HI, guys. I'm not sure if it could help you, but you could take one minues to try this.
microsoft/WSL#3988 (comment)
I seem to have fixed this by going to the registry
Computer\HKEY_CURRENT_USER\Console\%SystemRoot%_System32_WindowsPowerShell_v1.0_powershell.exe
Computer\HKEY_CURRENT_USER\Console\%SystemRoot%_SysWOW64_WindowsPowerShell_v1.0_powershell.exe
and changing FaceName
to the font used in WSL Console.
I seem to have fixed this by going to the registry
Computer\HKEY_CURRENT_USER\Console\%SystemRoot%_System32_WindowsPowerShell_v1.0_powershell.exe Computer\HKEY_CURRENT_USER\Console\%SystemRoot%_SysWOW64_WindowsPowerShell_v1.0_powershell.exe
and changing
FaceName
to the font used in WSL Console.
I found this does not work for me. After changing both values to Consolas (my chosen font) and rebooting the computer, this still happens.
1 year from the last comment, my WSL terminal when running react-scripts happens to change to the same small font when it tries to launch browser. any fixes?
@dandeancook That sounds like a totally different root cause than this thread (which was tracked down to a root cause in Windows PowerShell). I'd file a new issue, and make sure to include your OS version number, Terminal version, etc.