Why does running PowerShell change my console font?

16

4

I have a strange problem on my laptop - when I run Powershell within an existing console window, the font choice for the window changes.

For example, this is cmd.exe immediately after opening the window: command console when opened

The fonts, window size and colours used are correct - the font is Lucida Console at 16pt.

Then, I run PowerShell and this is the result:

enter image description here

The font has changed to "Raster Font" at 12x16 pixels! Other window properties - colours, row count, column count - are unchanged.

Any idea why it switches?

Note: while researching this - because the Raster Font is horrendously ugly and it bugs me - I have found others reporting problems setting the font for the powershell console window (such as the question "Cannot change powershell default font to Lucida Console"). Though my problem is different (since I'm starting Powershell from an existing console window, not from the start screen), I suspect a solution for one might help the other.

Bevan

Posted 2014-01-24T21:00:46.227

Reputation: 1 162

You could use ConEmu and avoid the problem altogether. – dangph – 2014-01-29T03:55:50.653

@ChrisLively ah I hadn't realised that answer was only posted today. For some reason I thought it was much older. i'll remove my comment. – barlop – 2014-05-22T21:08:22.250

Answers

2

This is FYI at least in case it helps anyone for a quick resolution. This may not answer the WHY but it gives a way to potentially fix or fix quickly moving forward if or as-needed.

Go to TechNet SetConsoleFont and see the details there and then follow the instructions below and look at the resources section below as well.

This is where the SetConsoleFont module comes in. Before you can use the Set-ConsoleFont cmdlet, you have to import the module. First, copy the module to a local editor. Note that when I copied the text, the last line had an unwanted line break. Make sure that the last line of the module looks like this:

Export-ModuleMember -Variable _DefaultFont, _hConsoleScreen -Function Set-ConsoleFont, Get-ConsoleFontInfo

Next, you have to store the file in your module folder. With $env:PSModulePath on a PowerShell console, you can get a list of your module folders. For instance, you can store the SetConsoleFont module in the PowerShell module folder in the Documents directory using the file name SetConsoleFont.psm1, like this:

%USERPROFILE%\Documents\WindowsPowerShell\Modules\SetConsoleFont\SetConsoleFont.psm1

Then, you can import the module with:

Import-Module SetConsoleFont

You can now get a list of the available fonts and their dimensions with:

Get-ConsoleFontInfo | Format-Table -AutoSize

To set a font size, you have to choose a number from the nFont column:

Set-ConsoleFont 8

To change your font size to the default, you can run Set-ConsoleFont without an argument

RESOURCES

Pimp Juice IT

Posted 2014-01-24T21:00:46.227

Reputation: 29 425

2

I was having the exact same problem and it was driving me nuts. Here is what I did to correct it, hopefully it will work for you too:

1.) While in cmd.exe, run the powershell command.

2.) While at the powershell prompt in cmd.exe, go to the settings and change the font to Lucida Console.

3.) Exit the powershell prompt and while still in cmd.exe go to the settings and change the font to Lucida Console.

4.) As an extra step for good measure I ran start powershell from cmd.exe and changed the font there also.

5.) Smile now that my OCD is able to take a rest. Now when I go to start->run->cmd.exe and use the powershell command, it stays at Lucida Console.

I restarted the computer and reopened everything, and so far it seems to be sticking for me.

I hope that this helps you on your quest =)

Ozzy S

Posted 2014-01-24T21:00:46.227

Reputation: 314

1Thanks very much for the suggestion - but it didn't make a difference on my laptop. :-( – Bevan – 2014-05-27T21:46:38.783