Skip to content
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

Font in WSL Console window changes to Raster Fonts when Running a powershell.exe command with Consolas font #367

Closed
jay-tuckey opened this issue Feb 5, 2019 · 12 comments
Labels
Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Conhost For issues in the Console codebase Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.

Comments

@jay-tuckey
Copy link

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

  1. Delete HKEY_CURRENT_USER\Console to reset console to all default settings
  2. Run ubuntu console. You should now have these font settings:
    image
  3. Execute powershell.exe -command 'Write-output hi' - no font change, and it correctly echo 'hi' to the command line:
    image
  4. Execute powershell.exe -command 'Write-output hi' | cat - font changes to Raster Fonts, and windows resizes to match new font:
    image
    image

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.

@DHowett-MSFT
Copy link
Contributor

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 ...

@therealkenc
Copy link

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.....

@miniksa miniksa added Product-Conhost For issues in the Console codebase Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues labels Mar 4, 2019
@MichaelUrman
Copy link

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!

@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label May 17, 2019
@miniksa miniksa added Issue-Bug It either shouldn't be doing this or needs an investigation. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. and removed Mass-Chaos labels May 17, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label May 18, 2019
@miniksa
Copy link
Member

miniksa commented May 18, 2019

Dupe to #280

@wusticality
Copy link

This is still broken for me on the latest fast ring. Any word on this? It totally breaks my Emacs workflow.

@crramirez
Copy link

@harounhajem
Copy link

Still the issue here. Did assign a, variable=powershell.exe -File "somescript.ps1" then the bug occurs. It's a shame

@bookyue
Copy link

bookyue commented Feb 18, 2020

HI, guys. I'm not sure if it could help you, but you could take one minues to try this.
microsoft/WSL#3988 (comment)

@cifkao
Copy link

cifkao commented Jul 6, 2020

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.

@openjck
Copy link

openjck commented Sep 10, 2021

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.

@danqdinh
Copy link

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?

@zadjii-msft
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Rendering Text rendering, emoji, complex glyph & font-fallback issues Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Conhost For issues in the Console codebase Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.
Projects
None yet
Development

No branches or pull requests