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

Closed
opened 2026-01-30 21:54:54 +00:00 by claunia · 12 comments
Owner

Originally created by @jay-tuckey on GitHub (Feb 5, 2019).

This was discovered from the issue here: https://github.com/Microsoft/WSL/issues/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.

Originally created by @jay-tuckey on GitHub (Feb 5, 2019). This was discovered from the issue here: https://github.com/Microsoft/WSL/issues/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 1. Run ubuntu console. You should now have these font settings: ![image](https://user-images.githubusercontent.com/1253791/52247313-fa899380-2930-11e9-9cb0-60155285d252.png) 1. Execute `powershell.exe -command 'Write-output hi'` - no font change, and it correctly echo 'hi' to the command line: ![image](https://user-images.githubusercontent.com/1253791/52247398-48060080-2931-11e9-9e60-da158278692a.png) 1. Execute `powershell.exe -command 'Write-output hi' | cat` - font changes to Raster Fonts, and windows resizes to match new font: ![image](https://user-images.githubusercontent.com/1253791/52247443-74ba1800-2931-11e9-8fde-9b3414b43a5c.png) ![image](https://user-images.githubusercontent.com/1253791/52247460-87345180-2931-11e9-9907-579eaae7e9d3.png) Some notes on the behaviour that we discovered in the previous issue: * Doesn't occur in [wsltty](https://github.com/mintty/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.
claunia added the Product-ConhostArea-RenderingIssue-BugResolution-Duplicate labels 2026-01-30 21:54:54 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Feb 5, 2019):

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

@DHowett-MSFT commented on GitHub (Feb 5, 2019): 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 ...
Author
Owner

@therealkenc commented on GitHub (Feb 5, 2019):

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

@therealkenc commented on GitHub (Feb 5, 2019): > 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](https://github.com/lzybkr/PSReadLine/pull/771) to PSReadline was done back in the October 2018 timeframe. I did some PS [rain dancing](https://github.com/lzybkr/PSReadLine/pull/771) 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](https://github.com/PowerShell/PowerShell/releases) 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](https://github.com/lzybkr/PSReadLine/issues/542), 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.....
Author
Owner

@MichaelUrman commented on GitHub (Mar 14, 2019):

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!

@MichaelUrman commented on GitHub (Mar 14, 2019): 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!
Author
Owner

@miniksa commented on GitHub (May 18, 2019):

Dupe to #280

@miniksa commented on GitHub (May 18, 2019): Dupe to #280
Author
Owner

@wusticality commented on GitHub (Oct 9, 2019):

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

@wusticality commented on GitHub (Oct 9, 2019): This is still broken for me on the latest fast ring. Any word on this? It totally breaks my Emacs workflow.
Author
Owner

@crramirez commented on GitHub (Oct 9, 2019):

Check this: https://patrickwu.space/2019/08/03/wsl-powershell-raster-font-problem/

@crramirez commented on GitHub (Oct 9, 2019): Check this: https://patrickwu.space/2019/08/03/wsl-powershell-raster-font-problem/
Author
Owner

@harounhajem commented on GitHub (Nov 1, 2019):

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

@harounhajem commented on GitHub (Nov 1, 2019): Still the issue here. Did assign a, variable=`powershell.exe -File "somescript.ps1"` then the bug occurs. It's a shame
Author
Owner

@bookyue commented on GitHub (Feb 18, 2020):

HI, guys. I'm not sure if it could help you, but you could take one minues to try this.
https://github.com/microsoft/WSL/issues/3988#issuecomment-587328805

@bookyue commented on GitHub (Feb 18, 2020): HI, guys. I'm not sure if it could help you, but you could take one minues to try this. https://github.com/microsoft/WSL/issues/3988#issuecomment-587328805
Author
Owner

@cifkao commented on GitHub (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.

@cifkao commented on GitHub (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.
Author
Owner

@openjck commented on GitHub (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.

@openjck commented on GitHub (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.
Author
Owner

@danddinh commented on GitHub (Oct 28, 2022):

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?

@danddinh commented on GitHub (Oct 28, 2022): 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?
Author
Owner

@zadjii-msft commented on GitHub (Oct 28, 2022):

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

@zadjii-msft commented on GitHub (Oct 28, 2022): @dandeancook That sounds like a totally different root cause than this thread (which was tracked down to [a root cause in Windows PowerShell](https://github.com/microsoft/terminal/issues/280#issuecomment-517870239)). I'd file a new issue, and make sure to include your OS version number, Terminal version, etc.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#546